/* SAT-ITEC Support — Apple-style UI (RZ_Support) */
:root {
  --bg: #f5f5f7; --surface: #ffffff; --surface-2: #f9f9fb; --surface-3: #f2f2f5;
  --text: #1d1d1f; --muted: #6e6e73; --muted-2: #86868b;
  --accent: #0071e3; --accent-hover: #0077ed; --accent-soft: rgba(0,113,227,.10);
  --border: rgba(0,0,0,.08); --border-strong: rgba(0,0,0,.16);
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 10px 30px rgba(0,0,0,.06);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --radius: 16px; --radius-sm: 10px; --radius-xs: 8px;
  --green: #34c759; --orange: #ff9500; --red: #ff3b30; --blue: #0a84ff; --purple: #af52de; --gray: #8e8e93; --yellow: #ffcc00; --teal: #30b0c7;
  --topbar-h: 54px; --sidebar-w: 236px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", "Segoe UI", Inter, Roboto, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000; --surface: #1c1c1e; --surface-2: #232325; --surface-3: #2c2c2e;
    --text: #f5f5f7; --muted: #98989d; --muted-2: #8d8d92;
    --accent: #0a84ff; --accent-hover: #409cff; --accent-soft: rgba(10,132,255,.18);
    --border: rgba(255,255,255,.10); --border-strong: rgba(255,255,255,.2);
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.5);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.5);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 26px; } h2 { font-size: 19px; } h3 { font-size: 15px; }
p { margin: 0 0 10px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .tiny { font-size: 12px; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 10px; } .row.between { justify-content: space-between; } .row.wrap { flex-wrap: wrap; }
.grow { flex: 1; } .right { text-align: right; } .center { text-align: center; }
.stack > * + * { margin-top: 14px; }

/* Topbar */
.topbar { position: sticky; top: 0; z-index: 50; height: var(--topbar-h); display: flex; align-items: center; gap: 14px; padding: 0 18px;
  background: color-mix(in srgb, var(--surface) 72%, transparent); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand .logo { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, #0a84ff, #5e5ce6); display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; }
.topbar .search { flex: 1; max-width: 520px; margin-left: 10px; }
.topbar nav a { color: var(--text); padding: 6px 10px; border-radius: 8px; font-size: 14px; }
.topbar nav a.active, .topbar nav a:hover { background: var(--surface-3); text-decoration: none; }
.userchip { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.userchip .name { font-size: 13px; color: var(--muted); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-3); color: var(--muted); display: inline-grid; place-items: center;
  font-size: 12px; font-weight: 600; flex-shrink: 0; }
.avatar.staff { background: linear-gradient(135deg, #0a84ff, #5e5ce6); color: #fff; }
.avatar.customer { background: linear-gradient(135deg, #34c759, #30b0c7); color: #fff; }
.avatar.lg { width: 40px; height: 40px; font-size: 14px; }

/* Shell */
.shell { display: flex; min-height: calc(100vh - var(--topbar-h)); }
.sidebar { width: var(--sidebar-w); padding: 18px 12px; border-right: 1px solid var(--border); background: var(--surface-2); flex-shrink: 0; }
.sidebar .group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted-2); padding: 14px 10px 6px; }
.sidebar a.item { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 9px; color: var(--text); font-size: 14px; }
.sidebar a.item:hover { background: var(--surface-3); text-decoration: none; }
.sidebar a.item.active { background: var(--accent); color: #fff; }
.sidebar a.item .count { margin-left: auto; font-size: 12px; color: var(--muted); background: var(--surface-3); border-radius: 999px; padding: 1px 8px; }
.sidebar a.item.active .count { background: rgba(255,255,255,.25); color: #fff; }
.sidebar .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.content { flex: 1; padding: 26px 30px 60px; min-width: 0; }
.content.narrow { max-width: 860px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; }

/* Cards */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.card .card-body { padding: 18px 20px; }
.card .card-head { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.card .card-head h2, .card .card-head h3 { margin: 0; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 999px; border: 1px solid transparent; font: inherit; font-size: 14px;
  font-weight: 500; cursor: pointer; background: var(--surface-3); color: var(--text); transition: background .15s, transform .05s; white-space: nowrap; }
.btn:hover { background: color-mix(in srgb, var(--surface-3) 80%, var(--muted) 20%); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--red); color: #fff; }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-sm { padding: 5px 11px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn-link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }

/* Forms */
.input, .select, .textarea { width: 100%; font: inherit; font-size: 14px; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 9px 12px; outline: none; transition: box-shadow .15s, border-color .15s; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.select { appearance: none; -webkit-appearance: none; padding-right: 32px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' fill='none' stroke='%23888' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center; }
label.field { display: block; margin-bottom: 12px; }
label.field > span, .label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
input[type=file] { font-size: 13px; }
.search-input { position: relative; }
.search-input .input { padding-left: 34px; border-radius: 999px; background: var(--surface-3); border-color: transparent; }
.search-input .input:focus { background: var(--surface); border-color: var(--accent); }
.search-input svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted); }

/* Segmented control */
.seg { display: inline-flex; background: var(--surface-3); border-radius: 10px; padding: 3px; gap: 2px; }
.seg a, .seg button { padding: 5px 12px; border-radius: 8px; font-size: 13px; color: var(--text); border: 0; background: transparent; font: inherit; cursor: pointer; }
.seg a.active, .seg button.active { background: var(--surface); box-shadow: var(--shadow-sm); font-weight: 600; }
.seg a:hover { text-decoration: none; }

/* Pills */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.new { background: rgba(10,132,255,.14); color: #0a6cd9; }
.pill.open { background: rgba(255,149,0,.16); color: #b86500; }
.pill.pending { background: rgba(175,82,222,.14); color: #8a3fb3; }
.pill.resolved { background: rgba(52,199,89,.16); color: #1f8f3d; }
.pill.closed { background: rgba(142,142,147,.18); color: #6e6e73; }
@media (prefers-color-scheme: dark) {
  .pill.new { color: #6fb4ff; } .pill.open { color: #ffb45e; } .pill.pending { color: #d59bff; } .pill.resolved { color: #6ee08b; } .pill.closed { color: #b0b0b5; }
}
.prio { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.prio::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--gray); }
.prio.normal::before { background: var(--blue); } .prio.high::before { background: var(--orange); } .prio.urgent::before { background: var(--red); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--surface-3); color: var(--muted); font-size: 12px; }

/* Ticket list */
.tlist { display: flex; flex-direction: column; }
.tlist .trow { display: grid; grid-template-columns: 34px 1fr auto; gap: 14px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); color: inherit; }
.tlist .trow:last-child { border-bottom: 0; }
.tlist .trow:hover { background: var(--surface-2); text-decoration: none; }
.tlist .trow .subj { font-weight: 600; font-size: 14.5px; display: flex; gap: 8px; align-items: baseline; }
.tlist .trow .subj .num { color: var(--muted-2); font-weight: 500; font-size: 13px; font-family: var(--mono); }
.tlist .trow .meta { font-size: 13px; color: var(--muted); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }
.tlist .trow .side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; font-size: 12.5px; color: var(--muted); }
.tlist .trow.unread .subj { color: var(--text); }
.tlist .trow.unread::before { content: ""; position: absolute; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty .icon { font-size: 34px; margin-bottom: 8px; }

/* Ticket detail */
.ticket-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.thread { display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; gap: 12px; }
.msg .body { flex: 1; min-width: 0; }
.msg .bubble { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm); }
.msg.outbound .bubble { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 25%, var(--border)); }
.msg.internal .bubble { background: color-mix(in srgb, var(--yellow) 14%, var(--surface)); border-color: color-mix(in srgb, var(--yellow) 40%, var(--border)); }
.msg.system { justify-content: center; }
.msg.system .sys { font-size: 12.5px; color: var(--muted); background: var(--surface-3); padding: 4px 12px; border-radius: 999px; }
.msg .head { display: flex; gap: 8px; align-items: baseline; margin-bottom: 8px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.msg .head .who { font-weight: 600; color: var(--text); font-size: 14px; }
.msg .text { white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; font-size: 14.5px; line-height: 1.5; }
.msg .html { font-size: 14.5px; line-height: 1.5; overflow-wrap: anywhere; }
.msg .html blockquote { border-left: 3px solid var(--border-strong); margin: 8px 0; padding-left: 10px; color: var(--muted); }
.msg .html table { border-collapse: collapse; } .msg .html td, .msg .html th { border: 1px solid var(--border); padding: 3px 6px; }
.msg .html pre { background: var(--surface-3); padding: 8px; border-radius: 8px; overflow: auto; }
details.quote summary { cursor: pointer; color: var(--muted); font-size: 12.5px; margin-top: 8px; user-select: none; }
details.quote .text { color: var(--muted); margin-top: 6px; }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.attachments a { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 8px; background: var(--surface-3); font-size: 12.5px; color: var(--text); }
.attachments a:hover { background: var(--accent-soft); text-decoration: none; }
.event { display: flex; justify-content: center; }
.event span { font-size: 12.5px; color: var(--muted); }
.composer { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 14px 16px; margin-top: 18px; }
.composer .textarea { border: 0; padding: 4px 2px; min-height: 110px; background: transparent; box-shadow: none; }
.composer .textarea:focus { box-shadow: none; }
.composer .bar { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--border); padding-top: 12px; margin-top: 8px; flex-wrap: wrap; }
.composer .bar .select { width: auto; }
.inspector .card + .card { margin-top: 14px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; font-size: 13.5px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.inspector .select, .inspector .input { font-size: 13.5px; padding: 7px 10px; }

/* Tables */
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-2); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--border); }
table.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl tr:hover td { background: var(--surface-2); }
table.tbl td.actions { white-space: nowrap; text-align: right; }
table.tbl td form { display: inline; }

/* Flash */
.flash { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; font-size: 14px;
  background: color-mix(in srgb, var(--green) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--green) 35%, transparent); }
.flash.err { background: color-mix(in srgb, var(--red) 12%, var(--surface)); border-color: color-mix(in srgb, var(--red) 35%, transparent); }
.flash .x { margin-left: auto; background: none; border: 0; cursor: pointer; color: var(--muted); font-size: 16px; line-height: 1; }
.note { padding: 12px 14px; border-radius: 12px; background: var(--surface-3); font-size: 13.5px; color: var(--muted); }

/* Auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth .card { width: 100%; max-width: 400px; padding: 30px 30px 26px; }
.auth .logo { width: 52px; height: 52px; border-radius: 14px; background: linear-gradient(135deg, #0a84ff, #5e5ce6); display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 20px; margin: 0 auto 14px; }
.auth h1 { font-size: 22px; text-align: center; margin-bottom: 4px; }
.auth .sub { text-align: center; color: var(--muted); font-size: 14px; margin-bottom: 22px; }
.auth .btn { width: 100%; justify-content: center; padding: 11px; font-size: 15px; }
.auth .links { display: flex; justify-content: space-between; margin-top: 16px; font-size: 13px; }
.auth .foot { text-align: center; color: var(--muted-2); font-size: 12px; margin-top: 22px; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .v { font-size: 26px; font-weight: 600; letter-spacing: -.02em; }
.stat .l { font-size: 12.5px; color: var(--muted); }

.pager { display: flex; gap: 6px; justify-content: center; margin-top: 16px; }
.pager a { padding: 5px 11px; border-radius: 8px; background: var(--surface-3); color: var(--text); font-size: 13px; }
.pager a.active { background: var(--accent); color: #fff; }

/* Responsive */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .content { padding: 18px 16px 40px; }
  .ticket-layout { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .topbar .search { display: none; }
  .tlist .trow { grid-template-columns: 1fr auto; }
  .tlist .trow .avatar { display: none; }
  .mobile-nav { display: flex; gap: 6px; overflow-x: auto; padding: 0 0 12px; -webkit-overflow-scrolling: touch; }
  .mobile-nav a { white-space: nowrap; padding: 6px 12px; border-radius: 999px; background: var(--surface-3); color: var(--text); font-size: 13px; }
  .mobile-nav a.active { background: var(--accent); color: #fff; }
}
@media (min-width: 901px) { .mobile-nav { display: none; } }
