/* Zasone admin portal */
:root {
  --bg: #f6f8fc;
  --panel: #ffffff;
  --line: #e4e9f2;
  --line-strong: #d3dbe8;
  --text: #0f172a;
  --muted: #5b6b82;
  --primary: #0b5cff;
  --primary-soft: #eef4ff;
  --accent: #6d5dfb;
  --green: #15803d;
  --green-soft: #e9f8ef;
  --amber: #a16207;
  --amber-soft: #fff6e0;
  --red: #b91c1c;
  --red-soft: #fdecec;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px -16px rgba(15, 23, 42, 0.18);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; line-height: 1.2; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 18px; margin: 0 0 6px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 12px; font-weight: 700; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 13px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.icon { width: 20px; height: 20px; flex-shrink: 0; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 18px;
  background: var(--panel); border-right: 1px solid var(--line); padding: 20px 14px;
}
.brand { display: flex; align-items: center; gap: 8px; padding: 4px 8px 10px; }
.brand img { width: 120px; height: auto; }
.brand span { font-size: 11px; font-weight: 700; color: var(--accent); background: #f1efff; padding: 2px 8px; border-radius: 99px; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px; color: #334155; font-weight: 600;
}
.side nav a:hover { background: #f3f6fb; text-decoration: none; }
.side nav a.active { background: var(--primary-soft); color: var(--primary); }
.count {
  margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 99px;
  background: var(--primary); color: #fff; font-size: 12px; text-align: center;
}
.logout { margin-top: auto; display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding-top: 14px; }
.who { display: flex; flex-direction: column; min-width: 0; padding-left: 6px; }
.who strong { font-size: 14px; }
.who small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout button { margin-left: auto; border: 0; background: transparent; color: var(--muted); padding: 8px; border-radius: 8px; cursor: pointer; }
.logout button:hover { background: #f3f6fb; color: var(--text); }
.main { padding: 28px clamp(16px, 3vw, 40px) 60px; min-width: 0; max-width: 1240px; }

/* ---------- Page bits ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.head-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.back { display: inline-block; margin-bottom: 12px; font-weight: 600; font-size: 14px; color: var(--muted); }
.search input { width: min(340px, 100%); }
.filters { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 4px; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--muted); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.on { background: var(--primary-soft); color: var(--primary); }
.tabs-quiet { background: transparent; border-color: transparent; }

.flash { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-weight: 500; }
.flash-ok { background: var(--green-soft); color: var(--green); }
.flash-error { background: var(--red-soft); color: var(--red); }
.new-banner { margin-bottom: 12px; }
.new-banner a { display: block; text-align: center; padding: 10px; border-radius: 10px; background: var(--primary-soft); font-weight: 600; }

.badge { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.badge-blue { background: var(--primary-soft); color: var(--primary); }
.badge-violet { background: #f1efff; color: #5b47e0; }
.badge-cyan { background: #e6f8fc; color: #0e7490; }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-gray { background: #f1f4f8; color: #475569; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.empty { text-align: center; padding: 64px 20px; background: var(--panel); border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.empty .btn { margin-top: 14px; }

/* ---------- Forms ---------- */
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: #334155; }
input:not([type]), input[type='text'], input[type='email'], input[type='password'], input[type='search'], select, textarea {
  font: inherit; color: var(--text); background: #fff;
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 10px 12px; width: 100%;
}
textarea { resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(11, 92, 255, 0.15); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.narrow { max-width: 440px; }
.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; color: var(--muted); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line-strong); background: #fff; color: var(--text);
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover { background: #f6f8fc; text-decoration: none; }
.btn-primary { background: linear-gradient(135deg, #0b5cff, #6d5dfb); border-color: transparent; color: #fff; box-shadow: 0 4px 14px -6px rgba(11, 92, 255, 0.6); }
.btn-primary:hover { background: linear-gradient(135deg, #0a52e8, #5f4ff0); }
.btn-small { padding: 6px 10px; font-size: 13px; }
.btn-danger { color: var(--red); }

/* ---------- Inbox list ---------- */
.list { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list li + li { border-top: 1px solid var(--line); }
.list a { display: block; padding: 14px 18px; color: inherit; }
.list a:hover { background: #fafbfe; text-decoration: none; }
.list li.unread a { background: linear-gradient(90deg, rgba(11, 92, 255, 0.06), transparent 40%); box-shadow: inset 3px 0 0 var(--primary); }
.row-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-top time { margin-left: auto; font-size: 13px; color: var(--muted); }
.row-sub { font-weight: 600; font-size: 14px; margin-top: 4px; }
.row-preview { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { display: flex; gap: 14px; font-size: 12.5px; color: #7b8aa0; margin-top: 4px; flex-wrap: wrap; }
.unread .row-top strong::after { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-left: 8px; vertical-align: middle; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2); }

/* ---------- Conversation ---------- */
.ticket { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.thread-wrap { min-width: 0; }
.presence { font-size: 13px; font-weight: 600; color: var(--muted); background: #f1f4f8; padding: 4px 10px; border-radius: 99px; }
.presence.on { color: var(--green); background: var(--green-soft); }
.thread { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.msg { max-width: 82%; padding: 12px 14px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); }
.msg-head { display: flex; gap: 10px; align-items: baseline; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.msg-head time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.msg-body { white-space: normal; overflow-wrap: anywhere; }
.msg-visitor { align-self: flex-start; border-bottom-left-radius: 4px; }
.msg-staff { align-self: flex-end; background: var(--primary-soft); border-color: #d6e4ff; border-bottom-right-radius: 4px; }
.msg-note { align-self: center; max-width: 92%; background: #fffbea; border: 1px dashed #f1d48a; box-shadow: none; font-size: 14px; }
.msg-system { align-self: stretch; max-width: none; background: #f8fafc; box-shadow: none; }
.msg.fresh { animation: pop 0.4s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.composer { position: sticky; bottom: 12px; background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 12px; box-shadow: 0 12px 30px -18px rgba(15, 23, 42, 0.35); }
.composer textarea { border: 0; padding: 8px 4px; box-shadow: none; min-height: 80px; }
.composer.note-mode { background: #fffdf3; border-color: #f1d48a; }
.composer-tabs { display: flex; gap: 16px; padding: 0 4px 6px; border-bottom: 1px solid var(--line); }
.composer-tabs label { flex-direction: row; align-items: center; gap: 6px; font-weight: 600; cursor: pointer; }
.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 8px; border-top: 1px solid var(--line); flex-wrap: wrap; }

.ticket-side { position: sticky; top: 20px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: #f3f6fb; padding: 4px; border-radius: 10px; }
.seg button { font: inherit; font-size: 13px; font-weight: 600; border: 0; border-radius: 8px; padding: 8px 4px; background: transparent; color: var(--muted); cursor: pointer; }
.seg button.on { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12); }
dl { margin: 0; display: grid; grid-template-columns: 96px 1fr; gap: 8px 10px; font-size: 14px; }
dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; }
.grid-dl { grid-template-columns: 160px 1fr; margin-bottom: 16px; }

/* ---------- Tables ---------- */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; margin-bottom: 16px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--line); background: #fafbfe; }
td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td small { display: block; color: var(--muted); font-size: 12.5px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.actions { text-align: right; }
.actions > div { display: inline-flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.row-fields { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 12px; align-items: end; }
.copy-row { display: flex; gap: 8px; }
.invite-card { border-color: #cfe0ff; background: #f7faff; }

/* ---------- Auth ---------- */
body.auth { display: grid; place-items: center; min-height: 100vh; padding: 20px; background: radial-gradient(ellipse at 70% 0%, #e8efff, transparent 60%), var(--bg); }
.auth-card { width: min(400px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 32px; box-shadow: 0 24px 60px -30px rgba(15, 23, 42, 0.35); }
.auth-card img { width: 150px; height: auto; margin-bottom: 18px; }
.auth-card h1 { font-size: 22px; }
.auth-card .muted { margin-bottom: 20px; }
.auth-card .btn { width: 100%; margin-top: 4px; }

/* ---------- Small screens ---------- */
@media (max-width: 900px) {
  .ticket { grid-template-columns: 1fr; }
  .ticket-side { position: static; }
  .row-fields { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: sticky; top: 0; z-index: 10; height: auto; flex-direction: row; align-items: center; gap: 6px; padding: 8px 10px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .brand { padding: 0 4px; }
  .brand img { width: 84px; }
  .brand span { display: none; }
  .side nav { flex-direction: row; }
  .side nav a { padding: 8px 10px; }
  .side nav a span { display: none; }
  .who { display: none; }
  .logout { margin: 0 0 0 auto; border: 0; padding: 0; }
  .msg { max-width: 94%; }
  .grid-dl { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
