/* TicketDesk — plain CSS, no build step, no external resources (works offline on the LAN). */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1d2330;
  --muted: #6b7280;
  --border: #e3e6eb;
  --accent: #15803d;
  --accent-hover: #166534;
  --danger: #c62828;
  --warn: #b26a00;
  --topbar: #18181b;          /* near-black: the logo has dark green and white parts */
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  font-size: 15px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.45;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0; }
code { background: #eef1f6; padding: 1px 5px; border-radius: 4px; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.text-danger { color: var(--danger) !important; }

/* ---------- top bar */
.topbar { background: var(--topbar); color: #fff; border-bottom: 3px solid var(--accent); }
.topbar-inner {
  max-width: 1600px; margin: 0 auto; padding: 0 20px; height: 56px;
  display: flex; align-items: center; gap: 14px;
}
.brand { color: #fff; font-weight: 700; font-size: 1.1rem; white-space: nowrap;
         display: flex; align-items: center; gap: 12px; }
.brand-logo { height: 24px; width: auto; display: block; }
/* Medium screens: the logo alone identifies the site, so the name gives way to the menu. */
@media (max-width: 1439px) { .brand-name:not(.keep) { display: none; } }
.brand-name { padding-left: 12px; border-left: 1px solid #3f3f46; line-height: 24px; }
.brand:hover { text-decoration: none; }
.mainnav { display: flex; gap: 2px; }
.mainnav a { color: #d4d4d8; padding: 6px 9px; border-radius: 6px; }
.mainnav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.mainnav a.active { background: rgba(255,255,255,.14); color: #fff; }
.topsearch { margin-left: auto; flex: 0 1 260px; min-width: 120px; }
.topsearch input {
  width: 100%; border: 0; border-radius: 6px; padding: 7px 10px;
  background: rgba(255,255,255,.12); color: #fff;
}
.topsearch input::placeholder { color: #a1a1aa; }
.usermenu { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.usermenu a { color: #fff; }
.usermenu .linkbtn { color: #a1a1aa; }

/* ---------- layout */
.container { max-width: 1320px; margin: 0 auto; padding: 24px 20px 40px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.count { color: var(--muted); font-weight: 400; font-size: 1.1rem; margin-left: 6px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.card { overflow-x: auto; }
.grid-2 > *, .detail-grid > *, .form-grid > * { min-width: 0; }
.card.flush { padding: 0; }
.card.narrow { max-width: 560px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.card-head a { font-size: .9rem; }
.card-title { margin-bottom: 12px; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 0 0 24px; }

/* ---------- forms */
label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 12px; }
input, select, textarea {
  display: block; width: 100%; margin-top: 4px; font: inherit; font-weight: 400;
  padding: 8px 10px; border: 1px solid #cfd5de; border-radius: 6px; background: #fff; color: var(--text);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(21, 128, 61, .25); border-color: var(--accent); }
input[type=checkbox] { display: inline; width: auto; margin: 0 6px 0 0; }
label.check { display: inline-flex; align-items: center; font-weight: 400; margin: 0; white-space: nowrap; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px 2px; margin: 4px 0 0; }
legend { font-weight: 600; font-size: .88rem; padding: 0 6px; }
.field-error { color: var(--danger); font-size: .85rem; margin: -8px 0 12px; }
.stack > * { margin-bottom: 12px; }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 300px; gap: 28px; }
.form-actions { display: flex; align-items: center; gap: 14px; margin-top: 8px; }
.inline-form { display: flex; gap: 8px; margin-bottom: 14px; }
.inline-form input { margin: 0; }
.token-box { font-family: ui-monospace, Consolas, monospace; margin-top: 8px; }

.btn {
  display: inline-block; font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer;
  padding: 8px 14px; border-radius: 6px; border: 1px solid #cfd5de; background: #fff; color: var(--text);
  white-space: nowrap; text-align: center;
}
.btn:hover { background: #f2f4f8; text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.topbar .btn-primary { background: #22c55e; border-color: #22c55e; color: #052e16; }
.topbar .btn-primary:hover { background: #4ade80; border-color: #4ade80; }
.auth-logo { background: var(--topbar); border-radius: 10px; padding: 16px; margin-bottom: 18px;
             display: flex; justify-content: center; border-bottom: 3px solid var(--accent); }
.auth-logo img { height: 34px; width: auto; display: block; }
.btn-sm { padding: 5px 10px; font-size: .85rem; }
.btn-block { display: block; width: 100%; margin-top: 8px; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }

/* ---------- flash */
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; border: 1px solid; }
.flash-success { background: #ecf8f0; border-color: #b7e2c4; color: #1e5b33; }
.flash-error   { background: #fdecec; border-color: #f3c0c0; color: #8a1c1c; }
.flash-info    { background: #eef3fd; border-color: #c8d7f7; color: #1f3f8a; }

/* ---------- badges */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600;
  white-space: nowrap; border: 1px solid transparent;
}
.status-new         { background: #e8efff; color: #1f4fc4; }
.status-open        { background: #e3f6ec; color: #17673b; }
.status-in_progress { background: #fff3d6; color: #8a5a00; }
.status-waiting     { background: #f3e8ff; color: #6b2fb3; }
.status-resolved    { background: #e6f4f4; color: #10656a; }
.status-closed      { background: #eceef2; color: #555d6b; }
.badge-danger   { background: #fdecec; color: var(--danger); }
.badge-internal { background: #fff3d6; color: #8a5a00; }
.prio { font-size: .85rem; font-weight: 600; white-space: nowrap; }
.prio::before { content: "●"; margin-right: 5px; font-size: .7rem; vertical-align: 1px; }
.prio-low::before    { color: #9aa3b2; }
.prio-normal::before { color: #3b82f6; }
.prio-high::before   { color: #f59e0b; }
.prio-urgent         { color: var(--danger); }
.prio-urgent::before { color: var(--danger); }

/* ---------- tables */
table { width: 100%; border-collapse: collapse; }
table.tickets th, table.simple th {
  text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border);
}
table.tickets td, table.simple td { padding: 10px 12px; border-bottom: 1px solid #eef0f3; vertical-align: middle; }
table.tickets tbody tr:hover { background: #f8f9fb; }
table.tickets tr:last-child td { border-bottom: 0; }
table.compact td, table.compact th { padding: 8px 8px; }
.col-id { width: 56px; color: var(--muted); }
.col-title a { color: var(--text); font-weight: 600; }
tr.overdue .col-id { box-shadow: inset 3px 0 0 var(--danger); }
tr.inactive td { color: var(--muted); }
.empty { color: var(--muted); padding: 14px 4px; margin: 0; }
.card.flush .empty { padding: 18px; }

/* ---------- dashboard */
.stat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 14px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); color: var(--text); display: flex; flex-direction: column;
}
a.stat:hover { border-color: var(--accent); text-decoration: none; }
.stat-num { font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.stat-num small { font-size: 1.1rem; color: var(--muted); font-weight: 600; }
.stat-label { color: var(--muted); font-size: .85rem; }
.stat-warn .stat-num { color: var(--warn); }
.stat-danger .stat-num { color: var(--danger); }
.status-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.status-chip { padding: 5px 12px; border-radius: 999px; font-size: .85rem; }
.status-chip:hover { text-decoration: none; filter: brightness(.96); }

/* ---------- list filters */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px; }
.filters input, .filters select { width: auto; margin: 0; }
.filters input[type=search] { flex: 1 1 240px; }
.pager { display: flex; justify-content: center; align-items: center; gap: 14px; }

/* ---------- ticket detail */
.ticket-head { align-items: flex-start; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 8px; font-size: .9rem; }
.detail-grid { display: grid; grid-template-columns: 1fr 300px; gap: 18px; align-items: start; }
.prose { white-space: pre-wrap; word-wrap: break-word; }
.timeline { list-style: none; padding: 0; margin: 0 0 16px; }
.tl-event { font-size: .86rem; padding: 6px 0 6px 14px; border-left: 2px solid var(--border); margin-left: 6px; }
.tl-event .badge { font-size: .72rem; }
.tl-comment { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin: 10px 0; }
.tl-comment.internal { background: #fffaf0; border-color: #f2dfb5; }
.tl-head { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; font-size: .9rem; }
.reply { border-top: 1px solid var(--border); padding-top: 14px; }
.reply textarea { margin-top: 0; }
.reply-actions { display: flex; gap: 10px; align-items: center; justify-content: flex-end; margin-top: 10px; }
.reply-actions select { width: auto; margin: 0; }
.reply-actions .check { margin-right: auto; }
.side-form label { margin-bottom: 10px; }
.kv { display: grid; grid-template-columns: 90px 1fr; gap: 6px 10px; margin: 0; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.kv-wide { grid-template-columns: 130px 1fr; margin-bottom: 14px; }
.btn[disabled] { opacity: .5; cursor: default; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #f59e0b; vertical-align: 2px; }

/* ---------- auth pages */
.auth-page { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; }
.auth-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 30px; box-shadow: 0 8px 30px rgba(16, 24, 40, .08);
}
.auth-card h1 { font-size: 1.35rem; }
.auth-page .flash { width: 100%; max-width: 380px; }
.error-card { max-width: 560px; margin: 40px auto; }

/* ---------- responsive */
@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 1180px) {
  /* Not enough room for everything on one line: the search box moves to its own line. */
  .topbar-inner { height: auto; flex-wrap: wrap; padding: 10px 20px; row-gap: 10px; }
  .topsearch { margin-left: 0; order: 10; flex: 1 1 100%; }
  .usermenu { margin-left: auto; }
}
@media (max-width: 860px) {
  .grid-2, .detail-grid, .form-grid { grid-template-columns: 1fr; }
  .row-3 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar-inner { height: auto; flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .topsearch { margin-left: 0; order: 10; width: 100%; }
  .mainnav { flex-wrap: wrap; }
  .usermenu { flex-wrap: wrap; }
  .topsearch input { width: 100%; }
  .container { padding: 16px; }
  .reply-actions { flex-wrap: wrap; }
  .tl-event { line-height: 1.9; }
}

/* ---------- language switcher */
.langswitch { display: inline-flex; border: 1px solid rgba(255,255,255,.25); border-radius: 6px; overflow: hidden; }
.langswitch button {
  background: none; border: 0; color: #d4d4d8; font: inherit; font-size: .78rem; font-weight: 600;
  padding: 3px 8px; cursor: pointer; letter-spacing: .03em;
}
.langswitch button:hover { background: rgba(255,255,255,.1); color: #fff; }
.langswitch button.active { background: rgba(255,255,255,.2); color: #fff; }
.langswitch.on-light { border-color: var(--border); }
.langswitch.on-light button { color: var(--muted); }
.langswitch.on-light button:hover { background: #f2f4f8; color: var(--text); }
.langswitch.on-light button.active { background: var(--accent); color: #fff; }
.auth-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }

/* ---------- attachments */
.attachments { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 10px; }
.attachments li {
  display: flex; flex-direction: column; gap: 4px; padding: 8px; max-width: 200px;
  border: 1px solid var(--border); border-radius: 8px; background: #fafbfc;
}
.attachments .thumb img { display: block; height: 90px; width: 182px; object-fit: cover; border-radius: 5px; }
.attachments .file { font-size: .86rem; word-break: break-all; line-height: 1.3; }
.attachments .meta-line { display: flex; gap: 8px; align-items: center; }
.attachments .linkbtn { font-size: .78rem; color: var(--muted); }
.attachments .linkbtn:hover { color: var(--danger); }
form.inline { display: inline; }
.fileinput { font-weight: 600; margin-top: 10px; }
.fileinput input[type=file] { border: 1px dashed #cfd5de; background: #fafbfc; padding: 10px; }
.notify-hint { margin: 6px 0 0; }

/* ---------- customers / portal */
.badge-customer { background: #e0f2fe; color: #075985; }
.tl-comment.from-customer { border-left: 3px solid #38bdf8; }
.tl-comment.from-staff { border-left: 3px solid var(--accent); }
.auth-links { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; font-size: .9rem; }
.auth-card h2 { font-size: 1.1rem; margin: 6px 0 10px; }
.portal-current h2 { font-size: 1.25rem; margin: 4px 0 8px; }
.portal-grid { display: grid; gap: 0; max-width: 900px; }
.narrow-wide { max-width: 760px; }
.grid-2.tight { gap: 10px; }

/* Take / Release buttons and dashboard drag and drop */
.col-action { width: 1%; white-space: nowrap; text-align: right; }
.col-action form { margin: 0; }
.btn-take { border-color: var(--accent); color: var(--accent); background: #fff; }
.btn-take:hover { background: var(--accent); color: #fff; }
.btn-release { color: #6b7280; background: #fff; }
tr[draggable="true"] { cursor: grab; }
tr.dragging { opacity: .45; }
.dropzone { position: relative; transition: box-shadow .12s, background-color .12s; }
.dropzone.drop-target { box-shadow: 0 0 0 2px var(--accent) inset; }
.dropzone.drop-active { background: #f0fdf4; box-shadow: 0 0 0 3px var(--accent) inset; }
.dropzone.drop-active::after { content: attr(data-drop-label); position: absolute; left: 50%; bottom: 10px;
  transform: translateX(-50%); background: var(--accent); color: #fff; padding: 4px 12px; border-radius: 999px;
  font-size: 13px; pointer-events: none; white-space: nowrap; }
.dnd-hint { margin: -6px 0 18px; }
@media (hover: none) { .dnd-hint { display: none; } }
