* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --border: #2d3a4f;
  --text: #e7ecf3;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --success: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --font: "Segoe UI", system-ui, sans-serif;
  --mono: "Cascadia Mono", Consolas, monospace;
}

html, body { height: 100%; font-family: var(--font); font-size: 13px; background: var(--bg); color: var(--text); }

.app-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ── Topbar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.topbar-left { display: flex; align-items: baseline; gap: 10px; }
.topbar h1 { font-size: 17px; font-weight: 700; }
.topbar-sub { font-size: 11px; color: var(--muted); }
.topbar-meta { display: flex; align-items: center; gap: 16px; color: var(--muted); font-size: 12px; }

.portal-return {
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--muted);
  text-decoration: none;
  font-size: 11px;
}
.portal-return:hover { color: var(--text); border-color: var(--primary); }

/* ── 3-column grid ── */
.main-grid {
  display: grid;
  grid-template-columns: 260px 1fr 300px;
  min-height: 0;
  overflow: hidden;
}

/* ── Left: ticket queue ── */
.ticket-list {
  border-right: 1px solid var(--border);
  background: var(--surface);
  overflow-y: auto;
  padding: 10px;
}

.queue-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
  padding: 0 2px;
}

.queue-count {
  background: var(--surface2);
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 10px;
}

.ticket-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 10px;
  margin-bottom: 4px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  transition: border-color 0.1s;
}

.ticket-item:hover { border-color: var(--primary); }
.ticket-item.active { border-color: var(--primary); background: rgba(59,130,246,0.15); }
.ticket-item.done { opacity: 0.65; }

.ticket-top-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.ticket-item .tid { font-size: 10px; color: var(--muted); flex-shrink: 0; }
.ticket-item .title { font-size: 12px; font-weight: 500; line-height: 1.35; }

.done-badge {
  margin-left: auto;
  font-size: 10px;
  color: var(--success);
  font-weight: 700;
}

.plat {
  display: inline-block;
  font-size: 9px;
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(255,255,255,0.07);
  color: var(--muted);
  flex-shrink: 0;
}

.plat-windows { background: rgba(59,130,246,0.15); color: #60a5fa; }
.plat-mac { background: rgba(156,163,175,0.15); color: #9ca3af; }
.plat-linux { background: rgba(251,191,36,0.15); color: #fbbf24; }
.plat-google { background: rgba(34,197,94,0.15); color: #4ade80; }
.plat-azure { background: rgba(99,102,241,0.15); color: #a5b4fc; }

/* ── Center: workspace ── */
.workspace {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #0b1018;
  overflow: hidden;
}

.ticket-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.ticket-header h2 { font-size: 15px; margin-bottom: 4px; }
.ticket-header p { color: var(--muted); font-size: 12px; line-height: 1.4; }

.header-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.header-ticket-num {
  font-size: 12px !important;
  font-weight: 700;
  color: var(--primary);
  margin: 0 !important;
}

.header-title {
  font-size: 15px;
  font-weight: 600;
  flex: 1;
}

.header-issue {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 8px;
  background: rgba(245,158,11,0.08);
  border-left: 3px solid var(--warn);
  padding: 8px 12px;
  border-radius: 0 6px 6px 0;
}

.ticket-meta {
  display: flex;
  gap: 16px;
  font-size: 11px;
  color: var(--muted);
  align-items: center;
}

.meta-resolved { color: var(--success); font-weight: 600; }

.tabs {
  display: flex;
  gap: 3px;
  padding: 7px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  flex-shrink: 0;
}

.tab-btn {
  padding: 5px 12px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.tab-btn:hover { background: var(--surface2); color: var(--text); }
.tab-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.panel-area {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  min-height: 260px;
}

.panel h3 { font-size: 13px; font-weight: 600; margin-bottom: 12px; color: var(--muted); }

/* ── Terminal ── */
.terminal {
  background: #0c0c0c;
  border-radius: 7px;
  font-family: var(--mono);
  font-size: 12px;
  overflow: hidden;
  border: 1px solid #222;
}

.terminal-output {
  padding: 12px;
  min-height: 200px;
  max-height: 320px;
  overflow-y: auto;
  color: #ccc;
  white-space: pre-wrap;
  line-height: 1.55;
}

.terminal-input-row {
  display: flex;
  align-items: center;
  border-top: 1px solid #2a2a2a;
  padding: 8px 12px;
  gap: 8px;
  background: #111;
}

.prompt { color: #4ade80; }
.terminal-input-row input {
  flex: 1;
  background: transparent;
  border: none;
  color: #fff;
  font: inherit;
  outline: none;
}

/* ── Buttons ── */
.btn {
  padding: 7px 13px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.1s, background 0.1s;
}
.btn:hover { border-color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }

/* ── Files panel ── */
.acl-table { width: 100%; border-collapse: collapse; font-size: 12px; margin: 10px 0; }
.acl-table th, .acl-table td { padding: 7px 10px; border: 1px solid var(--border); text-align: left; }
.acl-table th { background: var(--surface2); font-size: 11px; color: var(--muted); }

/* ── Logs panel ── */
.log-list { list-style: none; font-family: var(--mono); font-size: 11px; }
.log-list li {
  display: flex;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  line-height: 1.4;
}
.log-list li:hover { background: var(--surface2); }
.log-list li.highlight { background: rgba(245,158,11,0.1); border-left: 3px solid var(--warn); }
.log-time { color: var(--muted); flex-shrink: 0; }
.log-src { color: #60a5fa; flex-shrink: 0; }
.log-msg { color: var(--text); }

/* ── Workstation panel ── */
.ws-status { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.ws-stat { background: var(--surface2); border-radius: 7px; padding: 10px; }
.ws-stat .label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.ws-stat .value { font-size: 16px; font-weight: 700; margin-top: 4px; }
.val-ok { color: var(--success); }
.val-warn { color: var(--warn); }

.ws-error-banner {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.4);
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 12px;
  font-size: 12px;
  color: #fca5a5;
}

.ws-success-banner {
  background: rgba(34,197,94,0.1);
  border: 1px solid rgba(34,197,94,0.4);
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--success);
}

.ws-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }

.login-box {
  max-width: 340px;
  margin-top: 4px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  display: grid;
  gap: 6px;
}
.login-box strong { font-size: 12px; }
.login-box label { display: grid; gap: 3px; font-size: 11px; color: var(--muted); }
.login-box input {
  padding: 7px 8px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

/* ── External app panel ── */
.external-app-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.external-app-panel p { color: var(--muted); line-height: 1.5; font-size: 12px; }
.live-status {
  padding: 10px 12px;
  border-radius: 7px;
  background: var(--surface2);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  color: #cbd5e1;
}
.external-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.external-actions a.btn { text-decoration: none; display: inline-flex; align-items: center; }

/* ── Right: Resolution panel ── */
.resolution-panel {
  border-left: 1px solid var(--border);
  background: var(--surface);
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.res-empty { color: var(--muted); padding: 24px 0; text-align: center; font-size: 12px; }

.res-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.res-header h2 { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }

.res-done-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(34,197,94,0.15);
  color: var(--success);
  font-weight: 600;
}

.res-issue-box {
  background: rgba(245,158,11,0.08);
  border: 1px solid rgba(245,158,11,0.25);
  border-radius: 8px;
  padding: 10px 12px;
}

.res-issue-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--warn);
  margin-bottom: 5px;
  font-weight: 600;
}

.res-issue-text {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
}

/* Resolution how-to steps */
.res-steps-list { display: flex; flex-direction: column; gap: 6px; }

.res-step {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 8px 10px;
  background: var(--surface2);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.res-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.res-text {
  font-size: 11px;
  line-height: 1.5;
  color: var(--text);
}

/* Progress bar */
.res-progress { display: flex; flex-direction: column; gap: 5px; }
.res-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--muted);
}
.res-bar-track {
  height: 5px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
}
.res-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* Action buttons */
.res-actions {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.btn-test-fixed {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  padding: 10px;
  text-align: center;
  border-radius: 8px;
}
.btn-test-fixed:hover { background: #16a34a; border-color: #16a34a; }

.btn-reset { color: var(--muted); font-size: 11px; }

/* Checklist (step tracker) */
.res-checklist { margin-top: 4px; }

.res-checklist-header {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 600;
}

.res-check-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  line-height: 1.4;
  color: var(--muted);
}

.res-check-item.current { color: var(--text); }
.res-check-item.done { color: var(--muted); text-decoration: line-through; opacity: 0.65; }

.res-check-num {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  flex-shrink: 0;
  margin-top: 1px;
}

.res-check-item.current .res-check-num { background: var(--primary); border-color: var(--primary); color: #fff; }
.res-check-item.done .res-check-num { background: var(--success); border-color: var(--success); color: #fff; }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 11px 16px;
  border-radius: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 1000;
  animation: fadein 0.18s ease;
  font-size: 13px;
  max-width: 320px;
}
.toast.ok { border-color: var(--success); }
.toast.err { border-color: var(--danger); }

@keyframes fadein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.empty-state { text-align: center; color: var(--muted); padding: 48px 20px; }
.empty-icon { font-size: 36px; margin-bottom: 12px; }
.empty-state h3 { font-size: 15px; margin-bottom: 8px; color: var(--text); }
.empty-state p { font-size: 12px; line-height: 1.5; max-width: 280px; margin: 0 auto; }

/* ── Responsive ── */
@media (max-width: 1200px) {
  .main-grid { grid-template-columns: 220px 1fr 260px; }
}

@media (max-width: 900px) {
  .main-grid { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  .ticket-list { display: none; }
  .resolution-panel { border-left: none; border-top: 1px solid var(--border); max-height: 300px; }
}
