:root {
  --bg: #0a0a09;
  --panel: #111110;
  --panel-2: #171716;
  --line: #292825;
  --line-bright: #45433d;
  --text: #f3f2ed;
  --muted: #837f74;
  --accent: #ff5a1f;
  --accent-dim: rgba(255, 90, 31, 0.14);
  --lime: #d7fb3c;
  --up: #7dffa0;
  --down: #ff5c5c;
  --yellow: #ffd23f;
  --red: var(--down);
  --green: var(--up);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --radius: 3px;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

body {
  margin: 0;
  background: var(--bg);
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 28px 28px;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

#app { min-height: 100vh; }

@keyframes riseIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.centered {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.auth-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 340px;
  animation: riseIn 0.5s var(--ease) both;
}

.auth-card h1 {
  font-size: 15px;
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.auth-card p.sub {
  color: var(--muted);
  margin: 0 0 20px;
  font-size: 13px;
}

label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin: 14px 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

input, select, textarea {
  width: 100%;
  padding: 10px 11px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: #1a1a17;
}

button {
  cursor: pointer;
  border: 1px solid var(--line-bright);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), color 0.2s var(--ease), transform 0.15s var(--ease);
}

button:hover { border-color: var(--accent); color: var(--accent); }
button:active { transform: scale(0.97); }

button.secondary {
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--line);
}
button.secondary:hover { color: var(--text); border-color: var(--line-bright); }

button:not(.secondary):not(.danger) {
  background: var(--accent);
  color: #0a0a09;
  border-color: var(--accent);
}
button:not(.secondary):not(.danger):hover { background: #ff7040; border-color: #ff7040; color: #0a0a09; }

button.danger { background: transparent; color: var(--down); border-color: var(--down); }
button.danger:hover { background: var(--down); color: #0a0a09; }

button.row-delete-btn {
  padding: 0 8px;
  height: 26px;
  line-height: 24px;
  font-size: 16px;
  border-radius: 6px;
  opacity: 0.5;
}
button.row-delete-btn:hover { opacity: 1; }

button:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-row { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }

.error-box {
  background: rgba(255, 92, 92, 0.1);
  border: 1px solid var(--down);
  color: var(--down);
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-top: 12px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  gap: 12px;
  flex-wrap: wrap;
}

.topbar h1 {
  font-size: 13px;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar h1::before {
  content: "";
  width: 7px;
  height: 7px;
  background: var(--accent);
  display: inline-block;
}
.topbar h1 span { color: var(--muted); font-weight: 500; letter-spacing: 0.04em; text-transform: none; font-size: 11px; }

.tabs {
  display: flex;
  gap: 2px;
  padding: 10px 24px 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  padding: 9px 16px;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid transparent;
  border-bottom: none;
  white-space: nowrap;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
  flex-shrink: 0;
}

.tab.active {
  color: var(--accent);
  background: var(--bg);
  border-color: var(--line);
  border-top: 2px solid var(--accent);
  padding-top: 8px;
}

.tabbar-bg { background: var(--panel); border-bottom: 1px solid var(--line); }

main { padding: 20px; max-width: 1180px; margin: 0 auto; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 16px; }

.stat-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.stat-card .num { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 26px; font-weight: 700; line-height: 1; }
.stat-card .label {
  color: var(--muted);
  font-size: 10px;
  margin-top: 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
}

.panel::before, .panel::after {
  content: "";
  position: absolute;
  width: 9px;
  height: 9px;
  border-color: var(--line-bright);
  border-style: solid;
  border-width: 0;
  pointer-events: none;
}
.panel::before { top: -1px; left: -1px; border-top-width: 2px; border-left-width: 2px; }
.panel::after { bottom: -1px; right: -1px; border-bottom-width: 2px; border-right-width: 2px; }

.panel h2 {
  font-size: 12px;
  margin: 0 0 16px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel h2 .muted { color: var(--muted); font-weight: 500; font-size: 11px; text-transform: none; letter-spacing: 0; }

.table-scroll { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }

table { width: 100%; border-collapse: collapse; font-size: 12px; min-width: 560px; }
th {
  text-align: left;
  color: var(--muted);
  font-weight: 700;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 10px;
  white-space: nowrap;
}
td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr { transition: background 0.15s var(--ease); }
tr:hover td { background: var(--panel-2); }
tr:last-child td { border-bottom: none; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge.up { color: var(--up); }
.badge.down { color: var(--down); }
.badge.unknown { color: var(--muted); }

.dot { width: 6px; height: 6px; background: currentColor; flex-shrink: 0; }

@keyframes pulseDot { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.badge.up .dot { animation: pulseDot 2s ease-in-out infinite; }

.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.row-actions button { padding: 6px 10px; font-size: 10px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  main { padding: 14px; }
  .panel, .auth-card { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .tabs { padding: 8px 16px 0; }
  table { min-width: 480px; }
}

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.pill {
  display: inline-block;
  background: var(--panel-2);
  border: 1px solid var(--line-bright);
  border-radius: var(--radius);
  padding: 3px 8px;
  font-size: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.key-reveal {
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 14px;
  word-break: break-all;
}

.empty { color: var(--muted); font-size: 12px; padding: 24px 0; text-align: center; text-transform: uppercase; letter-spacing: 0.05em; }

.sec-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.sec-item:last-child { border-bottom: none; }
.sec-item .badge { flex-shrink: 0; margin-top: 2px; }
.sec-label { font-size: 13px; font-weight: 700; }

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: var(--radius);
  background: var(--down);
  color: #0a0a09;
  font-size: 9px;
  font-weight: 800;
  vertical-align: middle;
  margin-left: 4px;
}

.help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--panel-2);
  border: 1px solid var(--line-bright);
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  cursor: help;
  position: relative;
  margin-left: 2px;
  vertical-align: middle;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease);
}

.help:hover, .help:focus {
  color: var(--accent);
  border-color: var(--accent);
}

.help:hover::after, .help:focus::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 135%;
  left: 50%;
  transform: translateX(-50%);
  background: #1c1c19;
  border: 1px solid var(--line-bright);
  color: var(--text);
  padding: 8px 10px;
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  white-space: normal;
  width: 230px;
  line-height: 1.45;
  z-index: 30;
  cursor: default;
}

.section-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
  margin: 18px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.section-label:first-of-type { margin-top: 0; }

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.toolbar input, .toolbar select { width: auto; flex: 1 1 200px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }

.card-module {
  position: relative;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.card-module::before, .card-module::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  border-color: var(--line-bright);
  border-style: solid;
  border-width: 0;
  pointer-events: none;
}
.card-module::before { top: -1px; left: -1px; border-top-width: 2px; border-left-width: 2px; }
.card-module::after { bottom: -1px; right: -1px; border-bottom-width: 2px; border-right-width: 2px; }

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}
.card-title { font-weight: 800; font-size: 13px; line-height: 1.3; }
.card-subtitle { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; color: var(--muted); margin-top: 3px; word-break: break-all; }

.card-readouts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
  gap: 10px 8px;
  padding: 12px 0;
  border-top: 1px dashed var(--line);
  border-bottom: 1px dashed var(--line);
  margin-bottom: 12px;
}
.readout-label {
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
  margin-bottom: 5px;
}
.readout-value { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; font-weight: 700; }

.card-line { font-size: 11px; color: var(--muted); margin-bottom: 10px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }
.card-line::before { content: "\2192 "; }

.card-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.card-actions button { padding: 7px 10px; font-size: 10px; flex: 1 1 auto; }

.thread { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.thread-msg {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  max-width: 88%;
}
.thread-msg.staff { align-self: flex-start; border-left: 2px solid var(--accent); }
.thread-msg.customer { align-self: flex-end; border-right: 2px solid var(--line-bright); text-align: right; }
.thread-meta { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; font-weight: 700; }
.thread-body { font-size: 13px; line-height: 1.5; white-space: pre-wrap; text-align: left; }

@media (max-width: 640px) {
  .row-actions { gap: 4px; }
  .row-actions button { padding: 8px 8px; }
  .thread-msg { max-width: 100%; }
}

/* Language switcher — two small pills, active one picked out in the accent color */
.lang-switch { display: inline-flex; gap: 4px; }
.lang-switch button { padding: 6px 9px; font-size: 10px; }
.lang-switch button.lang-active { color: var(--accent); border-color: var(--accent); }
.auth-card .lang-switch { position: absolute; top: 16px; right: 16px; }
.auth-card { padding-top: 40px; }

/* Unread ticket indicator — a small dot plus a brighter left edge, so a new
   message reads as "something changed here" at a glance, not just a badge
   count you have to go find. */
.ticket-row { position: relative; }
.ticket-row.unread { border-left: 2px solid var(--accent); padding-left: 10px; }
.unread-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  margin-top: 4px;
  animation: pulseDot 2s ease-in-out infinite;
}

/* Domain-request option cards — a lightweight radio-button feel without a
   real radio input, since the whole card is the click target. */
.domain-option { cursor: pointer; transition: border-color 0.2s var(--ease); }
.domain-option:hover { border-color: var(--line-bright); }
.domain-option-selected { border-color: var(--accent); }

/* Storage usage bar (image uploads) */
.storage-bar { height: 8px; background: var(--panel-2); border-radius: 4px; overflow: hidden; margin-top: 12px; }
.storage-bar-fill { height: 100%; background: var(--accent); transition: width 0.3s var(--ease); }

/* A file input dressed up as a normal button */
.btn-file {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--accent);
  color: #0a0a09;
}
.btn-file:hover { background: #ff7040; border-color: #ff7040; }

.image-thumb { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius); display: block; }
.image-card .card-actions { margin-top: 10px; }

/* Tactile toggle switch — checkbox styled as a physical-feeling switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  width: 36px;
  height: 19px;
  background: var(--panel-2);
  border: 1px solid var(--line-bright);
  border-radius: 10px;
  position: relative;
  flex-shrink: 0;
  transition: background 0.25s var(--ease), border-color 0.25s var(--ease);
}
.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  background: var(--muted);
  border-radius: 50%;
  transition: transform 0.25s var(--ease), background 0.25s var(--ease);
}
.switch input:checked + .switch-track { background: var(--accent-dim); border-color: var(--accent); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(17px); background: var(--accent); }
.switch-label { font-size: 12px; color: var(--text); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }

.contact-field { margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px dashed var(--line); }
.contact-field:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.contact-field .switch { margin-top: 8px; }
