:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #1d2733;
  --muted: #6b7787;
  --line: #dde3ea;
  --accent: #1f6feb;
  --green: #1a7f37;
  --red: #c93030;
  --blue: #1f6feb;
  --amber: #b7791f;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.topnav {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 24px;
  background: #14273f;
  color: #fff;
}
.topnav a { color: #cfe0f5; text-decoration: none; }
.topnav a:hover { color: #fff; }
.topnav .brand { font-weight: 700; color: #fff; font-size: 1.05rem; }
.topnav .spacer { flex: 1; }
.topnav .whoami { color: #9db4ce; }
.link-btn {
  background: none; border: none; color: #cfe0f5; cursor: pointer;
  font: inherit; padding: 0;
}
.link-btn:hover { color: #fff; text-decoration: underline; }
.inline { display: inline; }

.container { max-width: 1200px; margin: 0 auto; padding: 24px; }
.footer { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 18px; }

h1 { font-size: 1.5rem; margin: 0 0 16px; }
h2 { font-size: 1.15rem; margin: 24px 0 10px; }
h3 { font-size: 1rem; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--red); font-weight: 600; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.crumbs { color: var(--muted); font-size: 0.9rem; }
.crumbs a { color: var(--accent); text-decoration: none; }

/* --- tiles ------------------------------------------------------------ */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 5px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  text-decoration: none;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(20, 39, 63, 0.06);
  transition: box-shadow 0.15s;
  position: relative;
}
.tile:hover { box-shadow: 0 4px 10px rgba(20, 39, 63, 0.12); }
.tile-open { border-left-color: var(--accent); }
.tile-breach { border-left-color: var(--red); }
.tile-title { font-weight: 600; }
.tile-big { font-size: 2rem; font-weight: 700; line-height: 1; }
.tile-sub { color: var(--muted); font-size: 0.8rem; }
.tile-row { display: flex; gap: 10px; font-size: 0.85rem; margin-top: 6px; }

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--line);
}
.badge-red { background: #fadcdc; color: var(--red); }
.badge-green { background: #d7ecdb; color: var(--green); }
.badge-blue { background: #dbe9fb; color: var(--blue); }
.badge-status-new { background: #dbe9fb; color: var(--blue); }
.badge-status-in_progress { background: #fdf1d7; color: var(--amber); }
.badge-status-waiting_customer { background: #eee4f8; color: #6b3fa0; }
.badge-status-resolved { background: #d7ecdb; color: var(--green); }
.badge-status-closed { background: var(--line); color: var(--muted); }
.badge-status-reopened { background: #fadcdc; color: var(--red); }

/* --- kanban ----------------------------------------------------------- */
.kanban {
  display: grid;
  grid-template-columns: repeat(6, minmax(170px, 1fr));
  gap: 12px;
  overflow-x: auto;
}
.kanban-col h3 { color: var(--muted); font-size: 0.85rem; text-transform: uppercase; }
.kanban-col .count { color: var(--ink); }
.card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  text-decoration: none;
  color: var(--ink);
  font-size: 0.9rem;
}
.card:hover { border-color: var(--accent); }
.card-unread { border-left: 4px solid var(--blue); }
.card-code { font-weight: 700; font-size: 0.8rem; color: var(--accent); margin-right: 6px; }
.card-title { display: block; margin-top: 3px; }
.card-meta { display: block; color: var(--muted); font-size: 0.8rem; margin-top: 3px; }

/* --- panels / detail -------------------------------------------------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 16px;
}
.two-col { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

.msg { border-top: 1px solid var(--line); padding: 10px 0; }
.msg-head { font-size: 0.85rem; margin-bottom: 4px; }
.msg-customer { background: #f6f9ff; border-radius: 6px; padding: 10px; }
.msg-kind-internal_note { background: #fffbea; border-radius: 6px; padding: 10px; }
.msg-kind-proposed_reply { background: #f3ecfd; border-radius: 6px; padding: 10px; }

.reply-form textarea, .csat-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font: inherit;
  resize: vertical;
}
.reply-actions { display: flex; gap: 16px; align-items: center; margin-top: 8px; }

button[type="submit"], .status-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font: inherit;
  cursor: pointer;
}
button[type="submit"]:hover, .status-btn:hover { filter: brightness(1.1); }
.status-btn { display: block; width: 100%; margin-bottom: 8px; background: #33445c; }

dl.meta { margin: 0; font-size: 0.9rem; }
dl.meta dt { color: var(--muted); margin-top: 8px; }
dl.meta dd { margin: 2px 0 0; }
ul.history { margin: 0; padding-left: 18px; font-size: 0.85rem; }

.table { width: 100%; border-collapse: collapse; background: var(--panel); }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-size: 0.85rem; }
.row-bad { background: #fdf3f3; }

/* --- login / public --------------------------------------------------- */
.login-box, .public-box {
  max-width: 640px;
  margin: 40px auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px 32px;
}
.login-box { max-width: 380px; }
.login-box label { display: block; margin-bottom: 12px; }
.login-box input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  font: inherit;
}
.status-line { font-size: 1.05rem; }

.stars { display: flex; gap: 10px; margin: 12px 0; }
.star-option { cursor: pointer; }
.star-option span {
  display: inline-block;
  width: 44px; height: 44px;
  line-height: 44px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 700;
}
.star-option input { display: none; }
.star-option input:checked + span { background: var(--accent); color: #fff; }
.product-block { margin-bottom: 8px; }
