/* ============================================================
   ServiceSync — stylesheet
   Aesthetic: calm "operations control" — deep teal-slate rail,
   cyan "sync" accent, the ticket workflow track as the signature.
   Full LTR + RTL support via logical properties.
   ============================================================ */

:root{
  --ink:#0c1a24; --ink-2:#33454f; --muted:#6b7b85;
  --bg:#eef2f5; --surface:#ffffff; --line:#e1e8ec; --line-2:#eef2f5;
  --accent:#0d8a98; --accent-deep:#075c66; --accent-bright:#16c2d4; --accent-wash:#e4f6f8;
  --rail:#0c1d24; --rail-2:#0f262e; --rail-line:#1d3a43; --rail-text:#9fc0c6; --rail-active:#10333b;
  --st-todo:#64748b; --st-in_progress:#d97706; --st-at_review:#6366f1; --st-complete:#16a34a;
  --urg-low:#64748b; --urg-medium:#d97706; --urg-high:#dc2626;
  --radius:11px; --radius-sm:8px;
  --shadow:0 1px 2px rgba(12,26,36,.05), 0 8px 24px -16px rgba(12,26,36,.22);
  --font:'Inter',system-ui,-apple-system,'Segoe UI',Roboto,sans-serif;
  --font-ar:'IBM Plex Sans Arabic','Inter','Segoe UI',Tahoma,sans-serif;
  --font-disp:'Space Grotesk','Inter',system-ui,sans-serif;
}
*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{
  font-family:var(--font); color:var(--ink); background:var(--bg);
  font-size:15px; line-height:1.5; -webkit-font-smoothing:antialiased;
}
body.rtl{font-family:var(--font-ar)}
body.rtl .brand-text em, body.rtl .ttitle{letter-spacing:0}
a{color:inherit;text-decoration:none}
h1,h2,h3{margin:0;font-family:var(--font-disp);font-weight:600;letter-spacing:-.01em}
h1{font-size:1.55rem} h2{font-size:1.02rem}
.muted{color:var(--muted)} .small{font-size:.82rem}
.req{color:var(--urg-high)}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}

/* ---------------- App shell ---------------- */
.shell{display:flex;min-height:100vh}
.sidebar{
  width:248px;flex-shrink:0;background:var(--rail);color:var(--rail-text);
  display:flex;flex-direction:column;position:sticky;top:0;height:100vh;
  border-inline-end:1px solid var(--rail-line);
}
.brand{display:flex;align-items:center;gap:11px;padding:20px 18px 16px;color:#eafafb}
.brand-mark{display:flex}
.brand-text{display:flex;flex-direction:column;font-family:var(--font-disp);font-weight:700;font-size:1.18rem;line-height:1.05}
.brand-text em{font-style:normal;font-weight:400;font-size:.62rem;color:var(--rail-text);font-family:var(--font);margin-top:3px;opacity:.85}
body.rtl .brand-text em{font-family:var(--font-ar)}

.nav{padding:8px 12px;display:flex;flex-direction:column;gap:2px;flex:1;overflow-y:auto}
.nav-item{
  display:flex;align-items:center;gap:11px;padding:9px 12px;border-radius:var(--radius-sm);
  color:var(--rail-text);font-weight:500;font-size:.92rem;transition:background .15s,color .15s;
}
.nav-item .ico{opacity:.8}
.nav-item:hover{background:var(--rail-2);color:#dff6f8}
.nav-item.active{background:var(--rail-active);color:#fff}
.nav-item.active .ico{opacity:1;color:var(--accent-bright)}

.side-foot{padding:12px;border-top:1px solid var(--rail-line);display:flex;flex-direction:column;gap:10px}
.lang-toggle{display:flex;gap:4px;background:var(--rail-2);padding:3px;border-radius:8px}
.lang-toggle a{flex:1;text-align:center;padding:5px;border-radius:6px;font-size:.8rem;font-weight:600;color:var(--rail-text)}
.lang-toggle a.on{background:var(--accent);color:#031b1e}
.user-chip{display:flex;align-items:center;gap:9px}
.avatar{width:34px;height:34px;border-radius:9px;background:var(--accent);color:#03262b;
  display:grid;place-items:center;font-weight:700;font-size:.78rem;flex-shrink:0}
.avatar.sm{width:30px;height:30px;border-radius:8px;font-size:.7rem;background:var(--accent-wash);color:var(--accent-deep)}
.user-meta{display:flex;flex-direction:column;line-height:1.15;min-width:0;flex:1}
.user-meta strong{color:#eafafb;font-size:.84rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.user-meta em{font-style:normal;font-size:.7rem;color:var(--rail-text)}
.signout{color:var(--rail-text);display:flex;padding:6px;border-radius:7px}
.signout:hover{background:var(--rail-2);color:#fff}

/* ---------------- Main ---------------- */
.main{flex:1;min-width:0;display:flex;flex-direction:column}
.topbar{display:none;align-items:center;gap:10px;padding:10px 14px;background:var(--surface);border-bottom:1px solid var(--line)}
.hamburger{border:1px solid var(--line);background:var(--surface);border-radius:8px;width:38px;height:38px;font-size:1.1rem;cursor:pointer}
.topbar-spacer{flex:1}
.lang-mini{font-weight:600;font-size:.82rem;padding:7px 11px;border:1px solid var(--line);border-radius:8px}
.page{padding:26px 30px;max-width:1180px;width:100%;margin:0 auto}
.flash{margin:14px 30px 0;background:#e8f7ee;border:1px solid #b6e3c6;color:#13683a;
  padding:10px 14px;border-radius:var(--radius-sm);font-size:.9rem;max-width:1180px}

.page-head{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:22px}
.page-head h1{margin-bottom:3px}
.back{display:inline-block;color:var(--accent-deep);font-size:.85rem;font-weight:600;margin-bottom:6px}

/* ---------------- Buttons ---------------- */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:7px;cursor:pointer;
  font-family:inherit;font-weight:600;font-size:.9rem;padding:10px 16px;border-radius:var(--radius-sm);
  border:1px solid transparent;transition:filter .15s,background .15s,border-color .15s;white-space:nowrap}
.btn-primary{background:var(--accent);color:#03262b;border-color:var(--accent)}
.btn-primary:hover{filter:brightness(1.06)}
.btn-soft{background:var(--accent-wash);color:var(--accent-deep)}
.btn-soft:hover{background:#d6eff2}
.btn-ghost{background:transparent;color:var(--ink-2);border-color:var(--line)}
.btn-ghost:hover{background:var(--line-2)}
.btn-block{width:100%}
.btn-tiny{padding:6px 11px;font-size:.8rem}

/* ---------------- Cards ---------------- */
.card{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);
  padding:18px 20px;box-shadow:var(--shadow);margin-bottom:18px}
.card-head{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:14px}
.card-head h2{display:flex;align-items:center;gap:8px}
.count{background:var(--line-2);color:var(--muted);font-size:.72rem;font-weight:700;
  padding:1px 8px;border-radius:99px;font-family:var(--font)}
.link{color:var(--accent-deep);font-weight:600;font-size:.85rem}
.rule{border:none;border-top:1px solid var(--line);margin:16px 0}

.grid-2{display:grid;grid-template-columns:1fr 1fr;gap:18px}
.grid-2.align-start{align-items:start}

/* ---------------- Stats ---------------- */
.stats{display:grid;grid-template-columns:repeat(4,1fr);gap:14px;margin-bottom:20px}
.stat{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);
  padding:16px 18px;display:flex;flex-direction:column;gap:4px;position:relative;overflow:hidden;
  box-shadow:var(--shadow);transition:transform .15s}
.stat::before{content:"";position:absolute;inset-block:0;inset-inline-start:0;width:4px;background:var(--muted)}
.stat:hover{transform:translateY(-2px)}
.stat.st-todo::before{background:var(--st-todo)}
.stat.st-in_progress::before{background:var(--st-in_progress)}
.stat.st-at_review::before{background:var(--st-at_review)}
.stat.st-complete::before{background:var(--st-complete)}
.stat-num{font-family:var(--font-disp);font-size:1.95rem;font-weight:700;line-height:1}
.stat-lbl{font-size:.82rem;color:var(--muted);font-weight:500}

/* ---------------- Lists / feeds ---------------- */
.tlist{list-style:none;margin:0;padding:0;display:flex;flex-direction:column}
.tlist li a{display:flex;align-items:center;justify-content:space-between;gap:12px;
  padding:11px 4px;border-bottom:1px solid var(--line-2)}
.tlist li:last-child a{border-bottom:none}
.tlist li a:hover .ttitle{color:var(--accent-deep)}
.tlist-main{display:flex;align-items:center;gap:9px;min-width:0}
.ttitle{font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.tlist-meta{display:flex;align-items:center;gap:10px;flex-shrink:0}
.tid{font-family:var(--font-disp);font-weight:700;color:var(--accent-deep);font-size:.82rem}

.empty{text-align:center;padding:28px 10px;color:var(--muted)}
.empty .btn{margin-top:10px}
.empty-line{padding:6px 0 12px}

.feed{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:2px}
.feed li{display:flex;gap:11px;padding:9px 0;border-bottom:1px solid var(--line-2)}
.feed li:last-child{border-bottom:none}
.feed-dot{width:9px;height:9px;border-radius:99px;margin-top:6px;flex-shrink:0;background:var(--muted)}
.feed-dot.act-ticket_created{background:var(--accent)}
.feed-dot.act-status_changed{background:var(--st-in_progress)}
.feed-dot.act-assigned,.feed-dot.act-reassigned{background:var(--st-at_review)}
.feed-dot.act-note_added{background:var(--muted)}
.feed-dot.act-message{background:var(--accent-bright)}
.feed-dot.act-company_added,.feed-dot.act-user_added{background:var(--st-complete)}
.feed p{margin:0;font-size:.88rem}
.feed time{font-size:.74rem;color:var(--muted)}
.feed a{color:var(--accent-deep);font-weight:600}
.feed-lg li{padding:11px 0}
.feed-day{border-bottom:none!important;padding:14px 0 4px!important}
.feed-day span{font-size:.72rem;font-weight:700;letter-spacing:.04em;text-transform:uppercase;color:var(--muted)}

/* ---------------- Pills / status / urgency ---------------- */
.pill{display:inline-flex;align-items:center;gap:6px;font-size:.76rem;font-weight:600;
  padding:3px 10px;border-radius:99px;white-space:nowrap}
.pill i{width:7px;height:7px;border-radius:99px;background:currentColor}
.st-todo{background:#eef1f4;color:#4a5963} .st-todo i{background:var(--st-todo)}
.st-in_progress{background:#fdf0e0;color:#9a5a05} .st-in_progress i{background:var(--st-in_progress)}
.st-at_review{background:#ecedfd;color:#4045b8} .st-at_review i{background:var(--st-at_review)}
.st-complete{background:#e7f6ec;color:#137a3b} .st-complete i{background:var(--st-complete)}
.urg{font-size:.74rem;font-weight:600;padding:2px 9px;border-radius:6px}
.urg-low{background:#eef1f4;color:#4a5963}
.urg-medium{background:#fdf0e0;color:#9a5a05}
.urg-high{background:#fceaea;color:#b4232a}

/* ---------------- Workflow track (signature) ---------------- */
.track-wrap{padding:20px 24px}
.track{display:flex;align-items:center;gap:0}
.track-step{display:flex;flex-direction:column;align-items:center;gap:7px;flex-shrink:0}
.track-step .dot{width:18px;height:18px;border-radius:99px;border:2px solid var(--line);
  background:var(--surface);position:relative;transition:.2s}
.track-step label{font-size:.74rem;font-weight:600;color:var(--muted);white-space:nowrap}
.track-step.done .dot{background:var(--accent);border-color:var(--accent)}
.track-step.done .dot::after{content:"";position:absolute;inset:0;background:no-repeat center/10px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23032b30' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5 9-11'/%3E%3C/svg%3E")}
.track-step.now .dot{border-color:var(--accent);box-shadow:0 0 0 4px var(--accent-wash)}
.track-step.now label{color:var(--accent-deep)}
.track-line{flex:1;height:2px;background:var(--line);margin:0 6px;margin-bottom:24px;min-width:24px}
.track-line.done{background:var(--accent)}

/* ---------------- Tables ---------------- */
.table-card{padding:0;overflow:hidden}
.ttable{width:100%;border-collapse:collapse;font-size:.9rem}
.ttable thead th{text-align:start;font-size:.72rem;font-weight:700;letter-spacing:.03em;
  text-transform:uppercase;color:var(--muted);padding:11px 16px;border-bottom:1px solid var(--line);background:var(--line-2)}
.ttable tbody td{padding:12px 16px;border-bottom:1px solid var(--line-2);vertical-align:middle}
.ttable tbody tr:last-child td{border-bottom:none}
.ttable tbody tr{cursor:pointer;transition:background .12s}
.ttable tbody tr:hover{background:var(--accent-wash)}
.cell-title{display:flex;flex-direction:column;gap:2px}
.cell-title strong{font-weight:600}
.ta-end{text-align:end}
.row-off{opacity:.55}
.tag-off{font-size:.68rem;background:#fceaea;color:#b4232a;padding:1px 7px;border-radius:5px;margin-inline-start:6px;font-weight:600}

/* ---------------- Forms ---------------- */
.stack{display:flex;flex-direction:column;gap:14px}
.stack.tight{gap:10px}
label{font-size:.85rem;font-weight:600;color:var(--ink-2);display:flex;flex-direction:column;gap:6px}
.lbl-sm{font-size:.78rem;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.03em}
input,select,textarea{font-family:inherit;font-size:.93rem;color:var(--ink);
  padding:10px 12px;border:1px solid var(--line);border-radius:var(--radius-sm);background:var(--surface);
  width:100%;font-weight:400;transition:border-color .15s,box-shadow .15s}
input:focus,select:focus,textarea:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-wash)}
textarea{resize:vertical;line-height:1.5}
.row-2{display:grid;grid-template-columns:1fr 1fr;gap:14px}
.form-card{max-width:560px}
.form-actions{display:flex;justify-content:flex-end;gap:10px;margin-top:4px}
.readonly-field{display:flex;flex-direction:column;gap:3px;background:var(--line-2);padding:10px 12px;border-radius:var(--radius-sm)}
.checks{display:flex;flex-direction:column;gap:7px;background:var(--line-2);padding:11px 13px;border-radius:var(--radius-sm)}
.chk{flex-direction:row;align-items:center;gap:8px;font-weight:500;font-size:.88rem}
.chk input{width:auto}

/* ---------------- Ticket detail layout ---------------- */
.grid-detail{display:grid;grid-template-columns:1fr 340px;gap:18px;align-items:start}
.col-main,.col-side{display:flex;flex-direction:column}
.tid-lg{font-family:var(--font-disp);color:var(--accent-deep)}
.kv{display:grid;grid-template-columns:1fr 1fr;gap:12px 18px;margin:0}
.kv>div{display:flex;flex-direction:column;gap:2px}
.kv dt{font-size:.72rem;text-transform:uppercase;letter-spacing:.03em;color:var(--muted);font-weight:700;margin:0}
.kv dd{margin:0;font-weight:500}
.desc{margin-top:16px;padding-top:14px;border-top:1px solid var(--line-2);color:var(--ink-2);font-size:.92rem;white-space:pre-line}

.notes{list-style:none;margin:0 0 14px;padding:0;display:flex;flex-direction:column;gap:13px}
.notes li{display:flex;gap:10px}
.note-head{display:flex;align-items:baseline;gap:8px}
.note-head time{font-size:.72rem;color:var(--muted)}
.notes p{margin:2px 0 0;font-size:.9rem;color:var(--ink-2)}
.note-form{display:flex;gap:8px;align-items:flex-end;border-top:1px solid var(--line-2);padding-top:14px}
.note-form textarea{flex:1}

/* ---------------- Chat ---------------- */
.chat-card{display:flex;flex-direction:column}
.chat-hint{font-size:.74rem;color:var(--muted);margin:-6px 0 10px}
.chat-stream{display:flex;flex-direction:column;gap:8px;max-height:380px;min-height:160px;
  overflow-y:auto;padding:4px 2px;margin-bottom:12px}
.chat-empty{text-align:center;margin:auto}
.msg{display:flex}
.msg.mine{justify-content:flex-end}
.bubble{max-width:80%;padding:8px 11px;border-radius:13px;font-size:.88rem;line-height:1.4;
  display:flex;flex-direction:column;gap:2px}
.msg.theirs .bubble{background:var(--line-2);border-bottom-left-radius:4px}
.msg.mine .bubble{background:var(--accent);color:#03262b;border-bottom-right-radius:4px}
body.rtl .msg.theirs .bubble{border-bottom-left-radius:13px;border-bottom-right-radius:4px}
body.rtl .msg.mine .bubble{border-bottom-right-radius:13px;border-bottom-left-radius:4px}
.msg-author{font-size:.7rem;font-weight:700;color:var(--accent-deep)}
.msg-time{font-size:.66rem;opacity:.65;align-self:flex-end}
.chat-form{display:flex;gap:8px;border-top:1px solid var(--line-2);padding-top:12px}
.chat-form input{flex:1}
.chat-form .btn{padding:10px 13px}

/* ---------------- People (admin) ---------------- */
.people{display:flex;flex-direction:column}
.person{border-bottom:1px solid var(--line-2)}
.person:last-child{border-bottom:none}
.person summary{display:flex;align-items:center;gap:11px;padding:11px 4px;cursor:pointer;list-style:none}
.person summary::-webkit-details-marker{display:none}
.person-meta{display:flex;flex-direction:column;line-height:1.2}
.person-meta em{font-style:normal;font-size:.76rem;color:var(--muted)}
.person-email{margin-inline-start:auto}
.person-edit{padding:6px 4px 16px}

/* ---------------- Filters ---------------- */
.filters{display:flex;gap:10px;margin-bottom:18px;flex-wrap:wrap;align-items:center}
.filters input[type=search]{flex:1;min-width:180px;max-width:320px}
.filters select{width:auto;min-width:150px}

/* ---------------- Auth ---------------- */
body.bare{background:var(--rail)}
.auth-wrap{min-height:100vh;display:grid;grid-template-columns:1.05fr 1fr}
.auth-art{background:
  radial-gradient(900px 500px at 15% -10%, #14424c 0%, transparent 55%),
  radial-gradient(700px 600px at 110% 120%, #0c5560 0%, transparent 50%),
  var(--rail);
  color:#dff6f8;display:flex;align-items:center;padding:48px;position:relative;overflow:hidden}
.auth-art::after{content:"";position:absolute;inset:0;
  background-image:linear-gradient(var(--rail-line) 1px,transparent 1px),linear-gradient(90deg,var(--rail-line) 1px,transparent 1px);
  background-size:46px 46px;opacity:.18;mask-image:radial-gradient(circle at 30% 40%,#000,transparent 75%)}
.auth-art-inner{position:relative;z-index:1;max-width:380px}
.auth-logo{display:inline-flex;margin-bottom:18px}
.auth-art h1{font-size:2.4rem;color:#fff;margin-bottom:8px}
.auth-art>.auth-art-inner>p{color:var(--rail-text);font-size:1.02rem;margin:0 0 26px}
.auth-points{list-style:none;padding:0;margin:0;display:flex;flex-direction:column;gap:13px}
.auth-points li{display:flex;align-items:center;gap:10px;color:#cdeef1;font-size:.92rem}
.auth-points li svg{color:var(--accent-bright);flex-shrink:0}

.auth-form{background:var(--surface);display:flex;flex-direction:column;justify-content:center;
  padding:48px 56px;position:relative}
.auth-form h2{font-size:1.7rem;margin-bottom:18px}
.auth-form .stack{max-width:360px}
.auth-form .btn-block{margin-top:4px}
.auth-lang{position:absolute;top:24px;inset-inline-end:32px;display:flex;gap:4px}
.auth-lang a{font-size:.8rem;font-weight:600;color:var(--muted);padding:5px 9px;border-radius:7px}
.auth-lang a.on{background:var(--accent-wash);color:var(--accent-deep)}
.auth-switch{font-size:.88rem;color:var(--muted);margin-top:18px;max-width:360px}
.auth-switch a{color:var(--accent-deep);font-weight:600}
.demo-box{margin-top:22px;max-width:360px;background:var(--line-2);border:1px solid var(--line);
  border-radius:var(--radius-sm);padding:13px 15px;display:flex;flex-direction:column;gap:5px}
.demo-box strong{font-size:.78rem;text-transform:uppercase;letter-spacing:.04em;color:var(--muted)}
.demo-box code{font-size:.78rem;color:var(--ink-2);font-family:var(--font-disp)}
.alert{background:#fceaea;border:1px solid #f1c4c4;color:#b4232a;padding:10px 13px;border-radius:var(--radius-sm);font-size:.88rem;margin-bottom:14px;max-width:360px}
.ok{background:#e8f7ee;border:1px solid #b6e3c6;color:#13683a;padding:10px 13px;border-radius:var(--radius-sm);font-size:.88rem;margin-bottom:14px;max-width:360px}

/* ---------------- Responsive ---------------- */
@media (max-width:980px){
  .grid-detail{grid-template-columns:1fr}
  .grid-2{grid-template-columns:1fr}
  .stats{grid-template-columns:repeat(2,1fr)}
  .auth-wrap{grid-template-columns:1fr}
  .auth-art{display:none}
}
@media (max-width:760px){
  .topbar{display:flex}
  .sidebar{position:fixed;inset-block:0;inset-inline-start:0;transform:translateX(-103%);
    z-index:50;transition:transform .22s;box-shadow:0 0 40px rgba(0,0,0,.3)}
  body.rtl .sidebar{transform:translateX(103%)}
  .sidebar.open{transform:translateX(0)}
  .page{padding:18px 16px}
  .flash{margin:14px 16px 0}
  .hide-sm{display:none}
  .row-2{grid-template-columns:1fr}
  .auth-form{padding:36px 24px}
  .page-head{flex-direction:column}
}

/* ============================================================
   v2.0 additions — activities, calendar, assets, people, etc.
   ============================================================ */

/* auth alias + tweaks */
.auth{min-height:100vh;display:grid;grid-template-columns:1.05fr 1fr}
.auth-art h2{font-size:2.1rem;color:#fff;margin-bottom:10px}
.auth-card{max-width:420px;width:100%}
.lang-mini-row{margin-top:18px;text-align:center;color:var(--muted);font-size:.85rem}
.lang-mini-row a{color:var(--accent-deep);font-weight:600}
.note{background:var(--accent-wash);border:1px solid #cbe9ed;color:var(--accent-deep);
  padding:9px 12px;border-radius:var(--radius-sm);font-size:.86rem;margin-bottom:12px}
.note.ok{background:#e8f7ee;border-color:#bce6cd;color:#157a3c}

/* page head / sections */
.page-head{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:18px}
.head-actions{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.sec-title{font-family:var(--font-disp);font-size:.95rem;color:var(--ink-2);margin:6px 0 12px}
.btn-sm{padding:6px 12px;font-size:.82rem}
.nowrap{white-space:nowrap}
.sep{border:none;border-top:1px solid var(--line);margin:16px 0}

/* clickable stat cards */
.stat-card{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);
  padding:16px 18px;display:flex;flex-direction:column;gap:3px;position:relative;
  box-shadow:var(--shadow);transition:transform .15s,box-shadow .15s}
.stat-card:hover{transform:translateY(-2px)}
.stat-card .stat-num{font-family:var(--font-disp);font-size:1.9rem;font-weight:700;line-height:1}
.stat-card .stat-lbl{font-size:.8rem;color:var(--muted);font-weight:500}
.stat-card.warn .stat-num{color:var(--urg-high)}
.stat-card.ok .stat-num{color:var(--st-complete)}
.stat-dot{width:9px;height:9px;border-radius:99px;background:var(--muted);position:absolute;inset-block-start:16px;inset-inline-end:16px}
.stat-dot.st-todo{background:var(--st-todo)}.stat-dot.st-in_progress{background:var(--st-in_progress)}
.stat-dot.st-at_review{background:var(--st-at_review)}.stat-dot.st-complete{background:var(--st-complete)}

/* mini upcoming list */
.mini-list{list-style:none;margin:0;padding:0}
.mini-list li{border-bottom:1px solid var(--line-2)}
.mini-list li:last-child{border-bottom:none}
.mini-list a{display:flex;align-items:center;gap:11px;padding:10px 0}
.mini-ico{font-size:1.1rem;width:26px;text-align:center;flex-shrink:0}
.mini-body{display:flex;flex-direction:column;gap:1px;flex:1;min-width:0}
.mini-body strong{font-size:.9rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.mini-body em{font-style:normal;font-size:.76rem;color:var(--muted)}
.mini-when{font-size:.76rem;color:var(--muted);white-space:nowrap}

/* tables (v2) */
.tbl-wrap{overflow-x:auto;margin:-4px}
.tbl{width:100%;border-collapse:collapse;font-size:.9rem;min-width:520px}
.tbl thead th{text-align:start;font-size:.72rem;text-transform:uppercase;letter-spacing:.03em;
  color:var(--muted);font-weight:700;padding:8px 12px;border-bottom:1px solid var(--line)}
.tbl tbody td{padding:11px 12px;border-bottom:1px solid var(--line-2);vertical-align:middle}
.tbl tbody tr:last-child td{border-bottom:none}
.tbl tbody tr[onclick]{cursor:pointer;transition:background .12s}
.tbl tbody tr[onclick]:hover{background:var(--accent-wash)}
.tbl .row-done strong{text-decoration:line-through;color:var(--muted)}

/* segmented toggle */
.seg{display:inline-flex;background:var(--line-2);border:1px solid var(--line);border-radius:9px;padding:3px}
.seg a{padding:6px 14px;border-radius:6px;font-size:.85rem;font-weight:600;color:var(--ink-2)}
.seg a.on{background:var(--surface);color:var(--accent-deep);box-shadow:var(--shadow)}

/* activity type pills */
.apill{display:inline-flex;align-items:center;gap:5px;padding:3px 9px;border-radius:99px;
  font-size:.78rem;font-weight:600;border:1px solid var(--line);background:var(--surface);white-space:nowrap}
.apill.at-call{background:#e7f7ee;border-color:#bfe6cf;color:#15803d}
.apill.at-email{background:#f1ecfe;border-color:#d8cbf7;color:#6d28d9}
.apill.at-meeting{background:#e7f0ff;border-color:#c4d8fb;color:#1d4ed8}
.apill.at-task{background:var(--accent-wash);border-color:#bfe6ea;color:var(--accent-deep)}
.apill.at-note{background:#fdf2e1;border-color:#f4dcb4;color:#b45309}
.apill.at-reminder{background:#fdeaef;border-color:#f6c9d6;color:#be123c}

/* activity / status state chips */
.astate{display:inline-flex;align-items:center;padding:3px 10px;border-radius:99px;font-size:.76rem;font-weight:600}
.astate.as-open{background:var(--accent-wash);color:var(--accent-deep)}
.astate.as-done{background:#e8f7ee;color:#157a3c}
.astate.as-cancelled{background:#f1f4f6;color:var(--muted)}

/* calendar */
.cal-card{padding:16px}
.cal-head{display:flex;align-items:center;justify-content:center;gap:18px;margin-bottom:14px}
.cal-head h2{font-family:var(--font-disp);min-width:170px;text-align:center}
.cal-grid{display:grid;grid-template-columns:repeat(7,1fr);gap:6px}
.cal-dow{font-size:.72rem;font-weight:700;text-transform:uppercase;color:var(--muted);text-align:center;padding-bottom:4px}
.cal-cell{min-height:96px;background:var(--line-2);border:1px solid var(--line);border-radius:8px;
  padding:5px 5px 6px;display:flex;flex-direction:column;gap:3px}
.cal-cell.empty{background:transparent;border:none}
.cal-cell.today{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent) inset}
.cal-date{font-size:.78rem;font-weight:700;color:var(--ink-2)}
.cal-cell.today .cal-date{color:var(--accent-deep)}
.cal-pill{font-size:.72rem;font-weight:600;padding:2px 6px;border-radius:5px;white-space:nowrap;overflow:hidden;
  text-overflow:ellipsis;background:var(--surface);border:1px solid var(--line);color:var(--ink-2)}
.cal-pill.at-call{background:#e7f7ee;color:#15803d}.cal-pill.at-email{background:#f1ecfe;color:#6d28d9}
.cal-pill.at-meeting{background:#e7f0ff;color:#1d4ed8}.cal-pill.at-task{background:var(--accent-wash);color:var(--accent-deep)}
.cal-pill.at-note{background:#fdf2e1;color:#b45309}.cal-pill.at-reminder{background:#fdeaef;color:#be123c}
.cal-pill.is-done{opacity:.5;text-decoration:line-through}

/* detail grid */
.detail-grid{display:grid;grid-template-columns:1fr 320px;gap:18px;align-items:start}
.detail-main{display:flex;flex-direction:column;gap:18px;min-width:0}
.detail-side{display:flex;flex-direction:column;gap:18px}
.detail-side h2{font-size:.95rem;margin-bottom:10px}
.side-actions{display:flex;flex-direction:column;gap:9px}
.detail-side select{margin-bottom:9px}
.track-card{overflow-x:auto}

/* kv labels (v2 span/strong form) */
.kv span{font-size:.72rem;text-transform:uppercase;letter-spacing:.03em;color:var(--muted);font-weight:700}
.kv strong{font-weight:600}
.desc{margin-top:14px;padding-top:14px;border-top:1px solid var(--line-2);white-space:pre-wrap;color:var(--ink-2);line-height:1.6}

/* forms */
.form-card{max-width:680px}
.form-row{display:grid;grid-template-columns:1fr 1fr;gap:14px}
.form-card label,.detail-side label{display:block;font-weight:600;font-size:.85rem;margin-bottom:12px}
.form-card label input,.form-card label select,.form-card label textarea,
.detail-side label input,.detail-side label select,.detail-side label textarea,
.inline-edit input{width:100%;margin-top:5px;font-weight:400}
.form-card small{font-weight:400}

/* notes list */
.note-form{display:flex;gap:10px;align-items:flex-start;margin-bottom:14px}
.note-form textarea{flex:1}
.note-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:12px}
.note-list li{background:var(--line-2);border-radius:var(--radius-sm);padding:10px 12px}
.note-meta{display:flex;justify-content:space-between;margin-bottom:4px}
.note-meta time{font-size:.74rem;color:var(--muted)}
.note-list p{margin:0;font-size:.9rem}

/* chips (company types) */
.chip-wrap{display:flex;flex-wrap:wrap;gap:8px}
.chip{background:var(--accent-wash);color:var(--accent-deep);border:1px solid #cbe9ed;
  padding:6px 13px;border-radius:99px;font-size:.85rem;font-weight:600}

/* role tags */
.role-tag{display:inline-flex;padding:2px 9px;border-radius:99px;font-size:.74rem;font-weight:600;background:var(--line-2);color:var(--ink-2)}
.role-tag.rt-super_admin{background:#0c1d24;color:#5eead4}
.role-tag.rt-admin{background:var(--accent-wash);color:var(--accent-deep)}

/* inline edit row */
.edit-row{display:none}
.edit-row.show{display:table-row}
.edit-row td{background:var(--line-2)}
.inline-edit{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.inline-edit input[type=password]{flex:1;min-width:180px}

/* nav separators */
.nav-sep{font-size:.66rem;font-weight:700;letter-spacing:.06em;text-transform:uppercase;
  color:var(--rail-text);opacity:.6;padding:14px 12px 5px}

/* chat bubbles (v2) */
.chat-stream{display:flex;flex-direction:column;gap:9px;max-height:340px;overflow-y:auto;padding:4px 2px 8px}
.bubble{max-width:78%;padding:8px 12px;border-radius:13px;font-size:.88rem;position:relative}
.bubble.them{align-self:flex-start;background:var(--line-2);border-bottom-left-radius:4px}
.bubble.me{align-self:flex-end;background:var(--accent-wash);border-bottom-right-radius:4px}
body.rtl .bubble.them{border-bottom-left-radius:13px;border-bottom-right-radius:4px}
body.rtl .bubble.me{border-bottom-right-radius:13px;border-bottom-left-radius:4px}
.bubble p{margin:0}
.bubble-author{display:block;font-size:.72rem;font-weight:700;color:var(--accent-deep);margin-bottom:2px}
.bubble time{display:block;font-size:.68rem;color:var(--muted);margin-top:3px;text-align:end}
.chat-form{display:flex;gap:9px;margin-top:10px}
.chat-form input{flex:1}

/* filters extra */
.filters .chk{display:inline-flex;align-items:center;gap:6px;font-size:.85rem;color:var(--ink-2)}

@media (max-width:900px){
  .detail-grid{grid-template-columns:1fr}
}
@media (max-width:760px){
  .auth{grid-template-columns:1fr}
  .stats{grid-template-columns:repeat(2,1fr)}
  .form-row{grid-template-columns:1fr}
  .cal-cell{min-height:72px}
  .cal-pill{font-size:.62rem}
  .page-head{flex-direction:column}
}

/* v2.1 — five roles, notifications, profile */
.role-tag.rt-supervisor{background:#e7f0ff;color:#1d4ed8}
.role-tag.rt-technician{background:#fdf2e1;color:#b45309}
.role-tag.rt-customer{background:#f1ecfe;color:#6d28d9}

/* notification bell */
.bell{position:relative;display:inline-flex;align-items:center;justify-content:center;width:38px;height:38px;
  border-radius:9px;color:var(--ink-2);border:1px solid var(--line);background:var(--surface);margin-inline-end:8px}
.bell:hover{background:var(--line-2)}
.bell .ico{width:20px;height:20px}
.bell-badge{position:absolute;top:-5px;inset-inline-end:-5px;min-width:18px;height:18px;padding:0 4px;
  background:var(--urg-high);color:#fff;border-radius:99px;font-size:.66rem;font-weight:700;
  display:flex;align-items:center;justify-content:center;line-height:1}
.feed li.unread{background:var(--accent-wash);border-radius:8px;padding-inline:8px}
.feed li.unread .feed-dot{background:var(--accent-bright)}
.inline-edit input[type=text]{flex:1;min-width:160px}

/* ============================================================
   v3.0 — themes (light/dark), accent presets, modern UI
   ============================================================ */

/* ---- accent presets (vivid vars; wash hand-tuned for light) ---- */
[data-accent="teal"]   {--accent:#0d8a98;--accent-deep:#075c66;--accent-bright:#16c2d4;--accent-wash:#e4f6f8}
[data-accent="indigo"] {--accent:#4f46e5;--accent-deep:#3730a3;--accent-bright:#818cf8;--accent-wash:#eceefe}
[data-accent="emerald"]{--accent:#059669;--accent-deep:#065f46;--accent-bright:#34d399;--accent-wash:#e6f7f0}
[data-accent="violet"] {--accent:#7c3aed;--accent-deep:#5b21b6;--accent-bright:#a78bfa;--accent-wash:#f1ecfe}
[data-accent="amber"]  {--accent:#d97706;--accent-deep:#92590a;--accent-bright:#fbbf24;--accent-wash:#fdf3e2}
[data-accent="rose"]   {--accent:#e11d48;--accent-deep:#9f1239;--accent-bright:#fb7185;--accent-wash:#fde7ec}
[data-accent="blue"]   {--accent:#2563eb;--accent-deep:#1e40af;--accent-bright:#60a5fa;--accent-wash:#e7f0ff}
[data-accent="slate"]  {--accent:#475569;--accent-deep:#1e293b;--accent-bright:#94a3b8;--accent-wash:#eef2f6}

/* ---- dark theme tokens ---- */
[data-theme="dark"]{
  --ink:#e7eef2; --ink-2:#aab9c2; --muted:#7f8e98;
  --bg:#0b1418; --surface:#11202733; --surface:#121e24; --line:#21333b; --line-2:#172731;
  --rail:#0a161b; --rail-2:#10242c; --rail-line:#1c333c; --rail-active:#13323a;
  --accent-wash:color-mix(in srgb, var(--accent) 24%, #0b1418);
  --shadow:0 1px 2px rgba(0,0,0,.4), 0 10px 30px -18px rgba(0,0,0,.7);
}
[data-theme="dark"] input,[data-theme="dark"] select,[data-theme="dark"] textarea{
  background:var(--surface);color:var(--ink);border-color:var(--line)}
[data-theme="dark"] .flash{background:color-mix(in srgb,var(--accent) 26%,#0b1418)}
@media (prefers-color-scheme: dark){
  [data-theme="system"]{
    --ink:#e7eef2; --ink-2:#aab9c2; --muted:#7f8e98;
    --bg:#0b1418; --surface:#121e24; --line:#21333b; --line-2:#172731;
    --rail:#0a161b; --rail-2:#10242c; --rail-line:#1c333c; --rail-active:#13323a;
    --accent-wash:color-mix(in srgb, var(--accent) 24%, #0b1418);
    --shadow:0 1px 2px rgba(0,0,0,.4), 0 10px 30px -18px rgba(0,0,0,.7);
  }
  [data-theme="system"] input,[data-theme="system"] select,[data-theme="system"] textarea{
    background:var(--surface);color:var(--ink);border-color:var(--line)}
}
body{transition:background .25s,color .25s}
.card,.nav-item,.btn,.stat-card{transition:background .2s,color .2s,border-color .2s,transform .15s,box-shadow .2s}

/* ---- brand logo + topbar buttons ---- */
.brand-logo{max-height:38px;max-width:160px;object-fit:contain;border-radius:8px}
.icon-btn{display:inline-flex;align-items:center;justify-content:center;width:38px;height:38px;border-radius:9px;
  border:1px solid var(--line);background:var(--surface);color:var(--ink-2);cursor:pointer;margin-inline-end:8px}
.icon-btn:hover{background:var(--line-2)}
.theme-toggle svg:nth-child(1){display:none}
.theme-toggle svg:nth-child(2){display:block}
[data-theme="dark"] .theme-toggle svg:nth-child(1){display:block}
[data-theme="dark"] .theme-toggle svg:nth-child(2){display:none}
@media (prefers-color-scheme: dark){
  [data-theme="system"] .theme-toggle svg:nth-child(1){display:block}
  [data-theme="system"] .theme-toggle svg:nth-child(2){display:none}
}

/* ---- entity edit/delete actions ---- */
.entity-actions{display:flex;gap:6px;flex-wrap:wrap}
.btn-danger{background:var(--urg-high);color:#fff;border-color:var(--urg-high)}
.btn-danger:hover{filter:brightness(.94)}
.btn-icon{display:inline-flex;align-items:center;gap:5px}

/* ---- analytics widgets ---- */
.viz-grid{display:grid;grid-template-columns:1fr 1fr;gap:18px;margin-bottom:18px}
.viz h2{margin-bottom:14px}
.bars{display:flex;flex-direction:column;gap:10px}
.bar-row{display:grid;grid-template-columns:120px 1fr 34px;align-items:center;gap:10px;font-size:.85rem}
.bar-track{height:10px;background:var(--line-2);border-radius:99px;overflow:hidden}
.bar-fill{height:100%;border-radius:99px;background:var(--accent);transition:width .6s cubic-bezier(.2,.8,.2,1)}
.bar-fill.st-todo{background:var(--st-todo)}.bar-fill.st-in_progress{background:var(--st-in_progress)}
.bar-fill.st-at_review{background:var(--st-at_review)}.bar-fill.st-complete{background:var(--st-complete)}
.donut-wrap{display:flex;align-items:center;gap:18px}
.donut{flex-shrink:0}
.donut-legend{display:flex;flex-direction:column;gap:6px;font-size:.82rem}
.donut-legend span{display:inline-flex;align-items:center;gap:7px}
.dot{width:10px;height:10px;border-radius:3px;display:inline-block}

/* ---- ticket photos ---- */
.photos{display:flex;flex-wrap:wrap;gap:10px;margin-top:6px}
.photo{position:relative;width:110px}
.photo-thumb{width:110px;height:90px;object-fit:cover;border-radius:10px;border:1px solid var(--line);cursor:zoom-in;display:block}
.photo-meta{display:flex;justify-content:space-between;align-items:center;margin-top:4px;font-size:.68rem;color:var(--muted)}
.photo-meta a{color:var(--accent-deep);font-weight:600}
.photo form{position:absolute;top:5px;inset-inline-end:5px}
.photo .x{background:rgba(0,0,0,.6);color:#fff;border:none;width:22px;height:22px;border-radius:6px;cursor:pointer;font-size:.8rem;line-height:1}
.uploader{border:1.5px dashed var(--line);border-radius:10px;padding:14px;text-align:center;cursor:pointer;color:var(--muted)}
.uploader:hover{border-color:var(--accent);color:var(--accent-deep);background:var(--accent-wash)}
.lightbox{position:fixed;inset:0;background:rgba(0,0,0,.85);display:flex;align-items:center;justify-content:center;z-index:9999;cursor:zoom-out;animation:fade .15s ease}
.lightbox img{max-width:92vw;max-height:92vh;border-radius:12px;box-shadow:0 20px 60px rgba(0,0,0,.6)}
@keyframes fade{from{opacity:0}to{opacity:1}}

/* ---- appearance page ---- */
.theme-opts{display:flex;gap:14px;flex-wrap:wrap}
.theme-opt{cursor:pointer;text-align:center}
.theme-opt input{position:absolute;opacity:0}
.theme-card{display:block;width:108px;height:70px;border-radius:11px;border:2px solid var(--line);position:relative;overflow:hidden;transition:border-color .15s}
.theme-opt input:checked + .theme-card{border-color:var(--accent)}
.theme-opt em{display:block;margin-top:6px;font-style:normal;font-size:.84rem;font-weight:600}
.tc-light{background:#eef2f5}.tc-dark{background:#0b1418}
.tc-system{background:linear-gradient(135deg,#eef2f5 0 50%,#0b1418 50% 100%)}
.tc-bar{position:absolute;top:0;inset-inline-start:0;width:34px;height:100%;background:var(--rail)}
.tc-dot{position:absolute;top:12px;inset-inline-start:46px;width:34px;height:8px;border-radius:99px;background:var(--accent)}
.accent-opts{display:flex;gap:14px;flex-wrap:wrap}
.accent-opt{cursor:pointer;text-align:center}
.accent-opt input{position:absolute;opacity:0}
.swatch{display:block;width:40px;height:40px;border-radius:11px;border:2px solid transparent;box-shadow:var(--shadow)}
.accent-opt input:checked + .swatch{border-color:var(--ink);transform:scale(1.05)}
.accent-opt em{display:block;margin-top:5px;font-style:normal;font-size:.78rem}
.sw-teal{background:#0d8a98}.sw-indigo{background:#4f46e5}.sw-emerald{background:#059669}.sw-violet{background:#7c3aed}
.sw-amber{background:#d97706}.sw-rose{background:#e11d48}.sw-blue{background:#2563eb}.sw-slate{background:#475569}
.form-actions{margin-top:16px}
.logo-current{display:flex;align-items:center;gap:14px;margin:6px 0}
.logo-current img{max-height:46px;max-width:150px;border:1px solid var(--line);border-radius:8px;padding:4px;background:var(--surface)}

/* subtle entrance animation for cards */
.page > .card,.page .stat-card,.page .viz{animation:rise .35s ease both}
@keyframes rise{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}

@media (max-width:900px){ .viz-grid{grid-template-columns:1fr} }

/* expandable inline edit rows (assets, companies, branches, users) */
.edit-row{display:none}
.edit-row.show{display:table-row}
.edit-row > td{background:var(--line-2);padding:14px}
.edit-row .form-card{background:transparent;border:none;box-shadow:none;padding:0}

/* ===================== v4: projects, assets QR, data ===================== */
.proj-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:14px;margin-bottom:8px}
.proj-card{display:block;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:16px;
  text-decoration:none;color:var(--ink);box-shadow:var(--shadow);transition:border-color .15s,transform .15s}
.proj-card:hover{border-color:var(--accent);transform:translateY(-1px)}
.proj-card.enquiry{border-inline-start:3px solid var(--accent)}
.proj-top{display:flex;justify-content:space-between;align-items:flex-start;gap:8px;margin-bottom:8px}
.proj-top strong{font-size:15px;line-height:1.3}
.proj-desc{color:var(--muted);font-size:13px;margin:0 0 12px}
.proj-prog{height:8px;border-radius:99px;background:var(--line-2);overflow:hidden}
.proj-prog-fill{height:100%;background:var(--accent);border-radius:99px;transition:width .3s}
.proj-meta{display:flex;flex-wrap:wrap;gap:6px 14px;margin-top:10px;font-size:12px;color:var(--muted)}
.count-badge{display:inline-block;min-width:20px;padding:1px 7px;border-radius:99px;background:var(--accent-wash);
  color:var(--accent);font-size:12px;font-weight:700;vertical-align:middle}

/* asset detail */
.detail-grid-kv .kv{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:14px}
.detail-grid-kv .kv>div{display:flex;flex-direction:column;gap:2px}
.detail-grid-kv .kv span{font-size:12px;color:var(--muted)}
.qr-box{display:inline-block;padding:10px;background:#fff;border:1px solid var(--line);border-radius:var(--radius-sm);margin:6px 0}

/* chat / comments */
.chat-list{display:flex;flex-direction:column;gap:10px;max-height:360px;overflow:auto;margin-bottom:12px}
.chat-msg{background:var(--bg);border:1px solid var(--line);border-radius:var(--radius-sm);padding:9px 12px;font-size:14px}
.chat-msg.mine{background:var(--accent-wash);border-color:transparent}
.chat-head{display:flex;gap:8px;align-items:baseline;margin-bottom:3px}
.chat-form{display:flex;gap:8px;align-items:flex-start}
.chat-form textarea{flex:1}

/* file list */
.file-list{list-style:none;padding:0;margin:0 0 12px;display:flex;flex-direction:column;gap:6px}
.file-list li{display:flex;align-items:center;gap:10px;flex-wrap:wrap;padding:8px 10px;background:var(--bg);border:1px solid var(--line);border-radius:var(--radius-sm)}
.file-list li .link{font-weight:600}

/* documents */
.doc-row{display:flex;justify-content:space-between;align-items:center;gap:10px;flex-wrap:wrap;
  padding:10px 0;border-bottom:1px solid var(--line)}
.doc-info{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.doc-actions{display:flex;gap:6px;flex-wrap:wrap}
.doc-edit{padding:12px 0}
.doc-new{margin-top:14px}
.doc-new>summary{display:inline-block;list-style:none;cursor:pointer}
.doc-new>summary::-webkit-details-marker{display:none}

/* members */
.member-pick{display:flex;flex-direction:column;gap:7px;max-height:240px;overflow:auto;margin-bottom:12px}
.member-chips{display:flex;flex-wrap:wrap;gap:6px}

/* activity timeline */
.timeline{list-style:none;padding:0;margin:0;display:flex;flex-direction:column;gap:10px}
.timeline li{font-size:13px;padding-inline-start:12px;border-inline-start:2px solid var(--line-2)}

/* progress range */
input[type=range]{width:100%;accent-color:var(--accent)}

@media(max-width:640px){.proj-grid{grid-template-columns:1fr}}
