:root {
  /* Tawsie brand: red + black, as on the corporate site */
  --red: #e8002d; --red-deep: #b5001f; --black: #0a0a0a; --graphite: #1a1a1a;
  --bg: #f4f4f3; --panel: #ffffff; --ink: #18181b; --muted: #6b6b70; --line: #e4e4e2;
  --brand: #e8002d; --brand-ink: #ffffff; --soft: #fdecef; --link: #c4001f;
  --ok: #138a4c; --warn: #b26a00; --bad: #c62a2a;
  --p-low: #8a8a90; --p-normal: #2f6fde; --p-high: #d07a00; --p-urgent: #e8002d;
  --radius: 6px; --shadow: 0 1px 2px rgba(0,0,0,.05);
  --display: "Barlow Condensed", "Vazirmatn", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg:#0a0a0a; --panel:#141414; --ink:#ececec; --muted:#8f8f95; --line:#262626; --soft:#2a0f14;
          --link:#ff4d6a; --shadow: none; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 14px/1.6 "Inter", "Vazirmatn", system-ui, sans-serif; }
[dir=rtl] body, body[dir=rtl] { font-family: "Vazirmatn", "Inter", system-ui, sans-serif; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 16px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
small, .muted { color: var(--muted); }
code, .mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; direction: ltr; unicode-bidi: embed; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

/* top bar: black like the corporate site, red underline on the active item */
.top { background: var(--black); color: #fff; position: sticky; top: 0; z-index: 5; border-top: 3px solid var(--red); }
.top .in { max-width: 1240px; margin: auto; display: flex; align-items: center; gap: 22px; padding: 0 16px; min-height: 58px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand img { width: 30px; height: 30px; display: block; }
.brand b { font-family: var(--display); font-weight: 700; font-size: 19px; letter-spacing: .06em; line-height: 1; }
.brand span { color: #9a9a9f; font-size: 12.5px; border-inline-start: 1px solid #333; padding-inline-start: 10px; line-height: 1; }
.nav { display: flex; gap: 2px; flex-wrap: wrap; align-self: stretch; }
.nav a { color: #a8a8ad; padding: 0 12px; display: flex; align-items: center; border-bottom: 2px solid transparent; font-size: 13.5px; }
.nav a:hover { color: #fff; text-decoration: none; }
.nav a.on { color: #fff; border-bottom-color: var(--red); }
.top .who { color: #e5e5e5; }
.top .out { color: #8a8a8f; }
.spacer { flex: 1; }
.lang a { padding: 3px 8px; border-radius: 3px; color: #8a8a8f; font-size: 12px; }
.lang a.on { background: var(--red); color: #fff; }
main { max-width: 1240px; margin: 20px auto; padding: 0 16px 60px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: minmax(0, 1fr) 320px; }
@media (max-width: 860px) { .cols-2 { grid-template-columns: 1fr; } }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 640px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; color: var(--ink); display: block; }
.stat:hover { border-color: var(--brand); text-decoration: none; }
.stat.on { border-color: var(--red); box-shadow: inset 0 -3px 0 var(--red); }
.stat b { display: block; font-family: var(--display); font-size: 34px; font-weight: 600; line-height: 1.1; }
.stat.bad b { color: var(--bad); }

/* forms */
input, select, textarea { font: inherit; color: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px var(--soft); }
textarea { min-height: 110px; resize: vertical; }
input[type=checkbox] { width: auto; }
label { display: block; font-size: 12.5px; color: var(--muted); margin: 0 0 4px; }
.field { margin-bottom: 12px; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 12px; }
.check { display: inline-flex; gap: 6px; align-items: center; color: var(--ink); font-size: 13.5px; margin-inline-end: 12px; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 8px 14px; border-radius: 4px; cursor: pointer; font: inherit; white-space: nowrap; }
.btn:hover { border-color: var(--brand); text-decoration: none; }
.btn.primary { background: var(--red); color: #fff; border-color: var(--red); font-weight: 500; }
.btn.primary:hover { background: var(--red-deep); border-color: var(--red-deep); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.filters { display: grid; grid-template-columns: 2fr repeat(3, 1fr) auto; gap: 8px; margin-bottom: 12px; }
@media (max-width: 760px) { .filters { grid-template-columns: 1fr 1fr; } }

/* table */
table { width: 100%; border-collapse: collapse; }
th { text-align: start; font-weight: 500; color: var(--muted); font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--soft); }
.tbl-wrap { overflow-x: auto; }
.t-title { font-weight: 500; color: var(--ink); }
.t-title:hover { color: var(--brand); }

/* badges */
.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--soft); color: var(--ink); white-space: nowrap; }
.s-open { background: #fdecef; color: #c4001f; } .s-in_progress { background: #fff4e0; color: #9a5b00; }
.s-waiting { background: #f1ecff; color: #6a3fd1; } .s-resolved { background: #e5f6ec; color: #13703f; } .s-closed { background: #eceef2; color: #5b6475; }
@media (prefers-color-scheme: dark) { .s-open,.s-in_progress,.s-waiting,.s-resolved,.s-closed { background: var(--soft); } }
.prio { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.prio::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.p-low { --c: var(--p-low); } .p-normal { --c: var(--p-normal); } .p-high { --c: var(--p-high); } .p-urgent { --c: var(--p-urgent); font-weight: 600; }
.overdue { color: var(--bad); font-weight: 600; }
.tag { font-size: 11.5px; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 0 6px; }

/* ticket page */
.desc { white-space: pre-wrap; word-wrap: break-word; }
.timeline { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.c { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; background: var(--panel); }
.c.internal { background: #fffbea; border-color: #f1e2a6; }
@media (prefers-color-scheme: dark) { .c.internal { background: #2a2614; border-color: #4a4220; } }
.c .h { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.c .h b { color: var(--ink); }
.ev { font-size: 12.5px; color: var(--muted); padding: 0 6px; }
.ev::before { content: "• "; }
.meta dt { color: var(--muted); font-size: 12px; margin-top: 10px; }
.meta dd { margin: 2px 0 0; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; background: #e5f6ec; color: #13703f; }
.flash.err { background: #fde8e8; color: #a12020; }
.token { background: var(--soft); border: 1px dashed var(--brand); padding: 12px; border-radius: 8px; word-break: break-all; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--line); }
.dot.on { background: var(--ok); }
details summary { cursor: pointer; color: var(--brand); }
.login { max-width: 360px; margin: 10vh auto; }
.pager { display: flex; gap: 6px; justify-content: center; margin-top: 14px; }

/* departments */
.dchip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; white-space: nowrap; }
.dchip::before { content: ""; width: 3px; height: 14px; border-radius: 2px; background: var(--dc, var(--muted)); }
.dstrip { display: flex; gap: 8px; overflow-x: auto; margin: -4px 0 16px; padding-bottom: 2px; }
.dstrip a { flex: 0 0 auto; background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--dc, var(--muted));
  border-radius: var(--radius); padding: 8px 12px; color: var(--ink); min-width: 150px; }
.dstrip a:hover { text-decoration: none; border-color: var(--dc); }
.dstrip a.on { box-shadow: 0 0 0 1px var(--dc) inset; }
.dstrip b { font-family: var(--display); font-size: 22px; font-weight: 600; margin-inline-end: 6px; }
.dstrip .od { color: var(--bad); font-size: 12px; }
.swatch { width: 14px; height: 14px; border-radius: 3px; display: inline-block; vertical-align: middle; background: var(--dc); }
input[type=color] { padding: 2px; height: 38px; }

/* ---------- login: follows the Tawsie corporate site ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(360px, 1fr); background: var(--black); color: #e5e5e5; }
.auth-hero { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; padding: 56px 64px;
  background: #0d0d0d url("/static/racks.svg") 0 0 / 360px 120px repeat; }
/* fade the rack wall into black where the text sits; a faint red glow from the edge */
.auth-hero::before { content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(10,10,10,.35) 0%, rgba(10,10,10,.55) 40%, rgba(10,10,10,.97) 78%),
              radial-gradient(70% 60% at 100% 100%, rgba(232,0,45,.16), transparent 70%); }
[dir=rtl] .auth-hero::before { background: linear-gradient(180deg, rgba(10,10,10,.35) 0%, rgba(10,10,10,.55) 40%, rgba(10,10,10,.97) 78%),
              radial-gradient(70% 60% at 0% 100%, rgba(232,0,45,.16), transparent 70%); }
.auth-hero > * { position: relative; }
.auth-hero .top-brand { position: absolute; top: 40px; inset-inline-start: 64px; }
.auth-hero h1 { font-family: var(--display); font-weight: 700; font-size: clamp(44px, 5.4vw, 76px); line-height: .98;
  letter-spacing: -.005em; color: #fff; margin: 0 0 20px; max-width: 15ch; }
[dir=rtl] .auth-hero h1 { font-family: "Vazirmatn", sans-serif; font-weight: 800; line-height: 1.25; font-size: clamp(36px, 4.2vw, 58px); max-width: 14ch; }
.auth-hero h1 em { font-style: normal; color: var(--red); }
.auth-hero p { color: #bdbdc2; font-size: 15.5px; max-width: 52ch; margin: 0 0 28px; }
.auth-kicker { color: #fff; font-size: 13px; margin-bottom: 18px; display: flex; align-items: center; gap: 10px; }
.auth-kicker::before { content: ""; width: 28px; height: 2px; background: var(--red); }
.auth-feats { display: flex; gap: 0; flex-wrap: wrap; border-top: 1px solid rgba(255,255,255,.14); padding-top: 18px; }
.auth-feats span { font-size: 13px; color: #d6d6da; padding-inline-end: 24px; margin-inline-end: 24px; border-inline-end: 1px solid rgba(255,255,255,.14); margin-bottom: 6px; }
.auth-feats span:last-child { border: 0; }
.auth-side { position: relative; display: flex; flex-direction: column; padding: 40px 56px; border-inline-start: 4px solid var(--red); }
.auth-side .row { justify-content: space-between; }
.auth-form { margin: auto 0; width: 100%; max-width: 380px; }
.auth-form h2 { font-size: 26px; color: #fff; margin: 0 0 6px; font-weight: 700; }
.auth-form .hint { color: #8a8a8f; margin: 0 0 28px; }
.auth-form label { color: #a8a8ad; font-size: 12.5px; }
.auth-form input { background: #141414; border: 1px solid #2a2a2a; color: #fff; border-radius: 4px; padding: 12px 14px; font-size: 15px; }
.auth-form input:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(232,0,45,.18); }
.auth-form .btn.primary { width: 100%; justify-content: center; padding: 12px; font-size: 15px; margin-top: 8px; }
.auth-form .flash { margin-bottom: 18px; }
.auth-foot { color: #6b6b70; font-size: 12px; }
.auth .lang a { color: #8a8a8f; }
.auth .lang a.on { background: var(--red); color: #fff; }
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { min-height: 300px; padding: 28px 24px; }
  .auth-hero .top-brand { top: 24px; inset-inline-start: 24px; }
  .auth-hero p, .auth-feats { display: none; }
  .auth-side { border-inline-start: 0; border-top: 4px solid var(--red); padding: 28px 24px 24px; }
  .auth-form { margin: 8px 0 32px; max-width: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .auth-hero h1, .auth-hero p, .auth-kicker { animation: rise .7s cubic-bezier(.2,.7,.2,1) both; }
  .auth-hero p { animation-delay: .08s; }
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
