:root {
  --bg: #080a1a;
  --bg-gradient: radial-gradient(ellipse 80% 60% at 50% -10%, #1a1f4a 0%, #0a0d22 45%, #080a1a 100%);
  --surface: #141838;
  --surface-2: #1c2148;
  --surface-hover: #242a58;
  --border: #2a2f5a;
  --border-strong: #3a4180;
  --primary: #3b44a3;
  --primary-hover: #4a55c2;
  --primary-light: #6b74d9;
  --primary-glow: rgba(107, 116, 217, 0.35);
  --accent: #F0742A;
  --accent-hover: #ff8640;
  --accent-glow: rgba(240, 116, 42, 0.3);
  --text: #e8eaf5;
  --text-dim: #9196b8;
  --text-muted: #6b6f8e;
  --danger: #e04b4b;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-pill: 999px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: var(--bg);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--primary-light); text-decoration: none; }
a:hover { color: var(--accent); }

code {
  background: rgba(0, 0, 0, 0.35);
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  font-size: 0.85em;
  font-family: ui-monospace, "SF Mono", Menlo, Monaco, monospace;
  color: var(--accent);
  border: 1px solid var(--border);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 0;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  text-decoration: none;
  user-select: none;
  font-family: inherit;
}

.btn:focus-visible {
  outline: 2px solid var(--primary-light);
  outline-offset: 2px;
}

.btn-primary {
  background: linear-gradient(180deg, #4a55c2 0%, #3b44a3 100%);
  color: #fff;
  box-shadow: 0 4px 14px var(--primary-glow), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 28px rgba(74, 85, 194, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  color: #fff;
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-accent {
  background: linear-gradient(180deg, #ff8640 0%, #F0742A 100%);
  color: #fff;
  box-shadow: 0 4px 14px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.btn-accent:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 28px rgba(240, 116, 42, 0.45);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  color: var(--text);
  border-color: var(--primary-light);
  background: rgba(107, 116, 217, 0.08);
}

.btn-full { width: 100%; padding: 0.95rem 1.5rem; font-size: 1rem; }
.btn-sm { padding: 0.5rem 1rem; font-size: 0.85rem; }

/* ---------- Forms ---------- */
.field {
  display: block;
  margin-bottom: 1.1rem;
}
.field-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-dim);
  margin-bottom: 0.45rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 0.8rem 1rem;
  font-size: 0.95rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  font-family: inherit;
}
.field input::placeholder { color: var(--text-muted); }
.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--primary-light);
  background: rgba(0, 0, 0, 0.35);
  box-shadow: 0 0 0 3px rgba(107, 116, 217, 0.18);
}
.field input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ---------- Auth / login ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}
.auth-card {
  position: relative;
  background: linear-gradient(180deg, rgba(28, 33, 72, 0.92) 0%, rgba(20, 24, 56, 0.92) 100%);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(107, 116, 217, 0.1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.auth-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--primary-light), transparent);
  opacity: 0.6;
}

.auth-brand { text-align: center; margin-bottom: 2rem; }
.auth-logo {
  width: 130px;
  height: auto;
  margin: 0 auto 1.25rem;
  display: block;
  filter: drop-shadow(0 4px 20px rgba(107, 116, 217, 0.2));
}
.auth-logo-white {
  background: #fff;
  padding: 20px;
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);
  width: 280px;
}
.auth-logo-sm { width: 80px; margin-bottom: 1rem; }
.auth-title {
  font-size: 1.35rem;
  margin: 0 0 0.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.auth-sub {
  color: var(--text-dim);
  margin: 0;
  font-size: 0.92rem;
}
.auth-form { margin-top: 0.5rem; }
.auth-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
  margin: 1.5rem 0 0;
}
.admin-disclosure {
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}
.admin-disclosure > summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.82rem;
  text-align: center;
  list-style: none;
  padding: 0.25rem;
  transition: color 0.15s;
}
.admin-disclosure > summary:hover { color: var(--text-dim); }
.admin-disclosure > summary::-webkit-details-marker { display: none; }
.admin-disclosure[open] > summary { color: var(--text-dim); margin-bottom: 0.75rem; }
.admin-disclosure .auth-form { margin-top: 0; }
.auth-footer {
  margin-top: 2rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: center;
}
.auth-footer a { color: var(--text-dim); }
.auth-footer a:hover { color: var(--accent); }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 0.9rem 2rem;
  background: rgba(14, 17, 42, 0.75);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text);
}
.brand-logo {
  height: 30px;              /* landscape wordmark — width follows aspect */
  width: auto;
  background: #fff;
  padding: 7px 12px;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.08);
  box-sizing: content-box;
  object-fit: contain;
  display: block;
}
.brand-text-wrap {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.brand-text {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.005em;
}
.brand-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 1px;
}
.topnav {
  display: flex;
  gap: 0.25rem;
  margin-left: auto;
}
.nav-link {
  padding: 0.55rem 1.1rem;
  color: var(--text-dim);
  text-decoration: none;
  border-radius: var(--radius-pill);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s;
}
.nav-link:hover {
  color: var(--text);
  background: var(--surface-2);
}

.user-panel {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.user-info {
  text-align: right;
  line-height: 1.2;
}
.user-name {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
}
.user-role {
  display: block;
  font-size: 0.7rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 2px;
  font-weight: 600;
}
.logout-form { margin: 0; }

/* ---------- Layout ---------- */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem;
}

.page-head { margin-bottom: 1.5rem; }
.page-head h1 {
  font-size: 1.6rem;
  margin: 0 0 0.35rem;
  font-weight: 700;
  letter-spacing: -0.015em;
}
.page-sub {
  color: var(--text-dim);
  margin: 0;
  font-size: 0.95rem;
}

/* ---------- Breadcrumbs ---------- */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
  flex-wrap: wrap;
}
.crumb {
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-pill);
  color: var(--text-dim);
  text-decoration: none;
  transition: all 0.15s;
  font-weight: 500;
}
.crumb:hover {
  background: var(--surface-2);
  color: var(--text);
}
.crumb-current {
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
}
.crumb-sep {
  color: var(--text-muted);
  font-weight: 400;
}

/* ---------- File list ---------- */
.file-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.file-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: linear-gradient(180deg, rgba(28, 33, 72, 0.6) 0%, rgba(20, 24, 56, 0.6) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text);
  transition: transform 0.15s, border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.file-row:hover {
  border-color: var(--primary-light);
  background: linear-gradient(180deg, rgba(40, 46, 98, 0.7) 0%, rgba(28, 33, 72, 0.7) 100%);
  transform: translateX(3px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  color: var(--text);
}
.file-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(107, 116, 217, 0.1);
  border-radius: var(--radius-md);
  flex-shrink: 0;
  color: var(--primary-light);
  border: 1px solid rgba(107, 116, 217, 0.15);
}
.file-icon svg { width: 22px; height: 22px; }
.folder-icon {
  background: rgba(240, 116, 42, 0.08);
  color: var(--accent);
  border-color: rgba(240, 116, 42, 0.18);
}

/* ---------- File-type icon colours ---------- */
.file-icon.icon-pdf     { background: rgba(239, 68, 68, 0.14);   color: #ff6b6b; border-color: rgba(239, 68, 68, 0.28); }
.file-icon.icon-word    { background: rgba(43, 92, 224, 0.16);   color: #7c93ea; border-color: rgba(43, 92, 224, 0.30); }
.file-icon.icon-excel   { background: rgba(34, 197, 94, 0.14);   color: #4ade80; border-color: rgba(34, 197, 94, 0.28); }
.file-icon.icon-ppt     { background: rgba(240, 116, 42, 0.14);  color: #ffa574; border-color: rgba(240, 116, 42, 0.28); }
.file-icon.icon-image   { background: rgba(168, 85, 247, 0.14);  color: #c084fc; border-color: rgba(168, 85, 247, 0.28); }
.file-icon.icon-video   { background: rgba(236, 72, 153, 0.14);  color: #f472b6; border-color: rgba(236, 72, 153, 0.28); }
.file-icon.icon-audio   { background: rgba(20, 184, 166, 0.14);  color: #2dd4bf; border-color: rgba(20, 184, 166, 0.28); }
.file-icon.icon-archive { background: rgba(234, 179, 8, 0.14);   color: #facc15; border-color: rgba(234, 179, 8, 0.28); }
.file-icon.icon-code    { background: rgba(6, 182, 212, 0.14);   color: #22d3ee; border-color: rgba(6, 182, 212, 0.28); }
.file-icon.icon-text    { background: rgba(148, 163, 184, 0.14); color: #cbd5e1; border-color: rgba(148, 163, 184, 0.28); }

.file-meta {
  flex: 1;
  min-width: 0;
}
.file-name {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-sub {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 3px;
}
.file-action { flex-shrink: 0; }
.download-btn {
  display: inline-block;
  padding: 0.45rem 1rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.15s;
}
.file-row:hover .download-btn {
  background: linear-gradient(180deg, var(--primary-hover) 0%, var(--primary) 100%);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 10px var(--primary-glow);
}
.chev {
  color: var(--text-muted);
  font-size: 1.75rem;
  transition: transform 0.15s, color 0.15s;
  line-height: 1;
}
.file-row:hover .chev {
  transform: translateX(4px);
  color: var(--accent);
}

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 4.5rem 2rem;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-dim);
}
.empty-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 1.25rem;
  color: var(--text-muted);
  opacity: 0.6;
}
.empty-icon svg { width: 100%; height: 100%; }
.empty-text {
  font-size: 1rem;
  margin: 0 0 0.5rem;
  color: var(--text);
}
.empty-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

/* ---------- Alerts ---------- */
.alert {
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  border: 1px solid transparent;
}
.alert-error {
  background: rgba(224, 75, 75, 0.1);
  border-color: rgba(224, 75, 75, 0.3);
  color: #ffb8b8;
}
.alert-info {
  background: rgba(107, 116, 217, 0.1);
  border-color: rgba(107, 116, 217, 0.3);
  color: #cfd4f5;
}

/* ---------- Notice / cards ---------- */
.notice {
  padding: 1rem 1.25rem;
  background: rgba(240, 116, 42, 0.08);
  border: 1px solid rgba(240, 116, 42, 0.25);
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
}
.notice strong { color: var(--accent); display: block; margin-bottom: 0.25rem; }
.notice p { margin: 0; color: var(--text-dim); font-size: 0.9rem; line-height: 1.6; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.card-head h2 {
  margin: 0 0 1.25rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.admin-form .btn { margin-top: 0.25rem; }

/* ---------- Tables ---------- */
.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.users-table th {
  text-align: left;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
}
.users-table td {
  padding: 0.9rem 0.85rem;
  border-bottom: 1px solid var(--border);
}
.users-table tr:last-child td { border-bottom: 0; }
.status-pill {
  display: inline-block;
  padding: 0.2rem 0.7rem;
  border-radius: var(--radius-pill);
  background: rgba(107, 116, 217, 0.15);
  color: var(--primary-light);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.empty-line {
  color: var(--text-muted);
  margin: 0;
  padding: 0.5rem 0;
  font-size: 0.9rem;
}

/* ---------- Admin file manager ---------- */
.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem 2rem;
  align-items: flex-end;
}
.action-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin: 0;
}
.action-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-right: 0.2rem;
  width: 100%;
}
.action-inline input[type="text"] {
  padding: 0.55rem 0.9rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  min-width: 220px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.action-inline input[type="text"]:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(107, 116, 217, 0.18);
}
.action-inline input[type="file"] {
  color: var(--text-dim);
  font-size: 0.85rem;
  max-width: 320px;
}
.action-inline input[type="file"]::file-selector-button {
  padding: 0.45rem 0.9rem;
  margin-right: 0.6rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.action-inline input[type="file"]::file-selector-button:hover {
  border-color: var(--primary-light);
  color: var(--text);
}
.action-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.file-row-admin {
  padding: 0;
  display: flex;
  align-items: stretch;
}
.file-row-admin .file-row-main {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  flex: 1;
  min-width: 0;
  text-decoration: none;
  color: var(--text);
}
.file-row-admin .file-row-main:hover {
  color: var(--text);
}
.row-delete-form {
  display: flex;
  align-items: center;
  padding-right: 0.75rem;
  margin: 0;
}
.btn-delete {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-delete:hover {
  background: rgba(224, 75, 75, 0.12);
  border-color: rgba(224, 75, 75, 0.35);
  color: #ff8888;
}
.btn-delete:focus-visible {
  outline: 2px solid var(--primary-light);
  outline-offset: 2px;
}

/* ---------- Activity log ---------- */
.activity-filters {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.filter-pill {
  padding: 0.45rem 1rem;
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid var(--border);
  transition: all 0.15s;
}
.filter-pill:hover { color: var(--text); border-color: var(--primary-light); background: var(--surface-2); }
.filter-pill-active {
  background: linear-gradient(180deg, var(--primary-hover), var(--primary));
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 4px 12px var(--primary-glow);
}
.filter-pill-active:hover { color: #fff; }

.activity-card { padding: 0; overflow: hidden; }
.activity-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.activity-table th {
  text-align: left;
  padding: 0.8rem 1rem;
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
}
.activity-table td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
}
.activity-table tbody tr:last-child td { border-bottom: 0; }
.activity-table tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
.activity-when {
  color: var(--text-dim);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
}
.activity-actor { font-weight: 600; }
.activity-details {
  color: var(--text-dim);
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}
.activity-path {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.82rem;
  color: var(--text);
  word-break: break-all;
}
.activity-size, .activity-role, .activity-ip {
  font-size: 0.75rem;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text-muted);
  white-space: nowrap;
}
.activity-role { color: var(--primary-light); border-color: rgba(107, 116, 217, 0.3); background: rgba(107, 116, 217, 0.08); }

.event-pill {
  display: inline-block;
  padding: 0.2rem 0.7rem;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  border: 1px solid transparent;
}
.pill-green { background: rgba(34, 197, 94, 0.12);   color: #4ade80; border-color: rgba(34, 197, 94, 0.28); }
.pill-red   { background: rgba(239, 68, 68, 0.12);   color: #ff8888; border-color: rgba(239, 68, 68, 0.28); }
.pill-blue  { background: rgba(107, 116, 217, 0.14); color: var(--primary-light); border-color: rgba(107, 116, 217, 0.3); }
.pill-amber { background: rgba(234, 179, 8, 0.12);   color: #facc15; border-color: rgba(234, 179, 8, 0.28); }
.pill-grey  { background: rgba(148, 163, 184, 0.12); color: #cbd5e1; border-color: rgba(148, 163, 184, 0.28); }

/* ---------- Blacklist panel ---------- */
.blacklist-head { display: flex; align-items: center; justify-content: space-between; }
.blacklist-head h2 { margin: 0 0 1.25rem; }
.inline-form { margin: 0 0 1.25rem; }
.blacklist-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.blacklist-table th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
}
.blacklist-table td {
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
}
.blacklist-table tr:last-child td { border-bottom: 0; }
.atrisk-head {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 1.25rem 0 0.5rem;
}

.users-live-table .user-username {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 2px;
}
.activity-ip-cell {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.82rem;
  color: var(--text-dim);
  white-space: nowrap;
}
.session-you {
  display: inline-block;
  padding: 0.2rem 0.7rem;
  border-radius: var(--radius-pill);
  background: rgba(107, 116, 217, 0.15);
  color: var(--primary-light);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: 1px solid rgba(107, 116, 217, 0.3);
}

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.25rem;
  padding: 0.25rem 0.25rem 2rem;
}
.pagination-info {
  font-size: 0.85rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.pagination-standalone {
  text-align: center;
  padding: 1.5rem 0;
}
.btn.btn-disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

/* ---------- Error page ---------- */
.error-title {
  font-size: 1.3rem;
  margin: 0 0 0.5rem;
  font-weight: 700;
}
.error-msg {
  color: var(--text-dim);
  margin: 0 0 1.5rem;
}
.error-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 3rem 2rem;
  text-align: center;
  max-width: 520px;
  margin: 2rem auto;
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .topbar {
    padding: 0.75rem 1rem;
    gap: 1rem;
    flex-wrap: wrap;
  }
  .brand-sub { display: none; }
  .topnav { margin-left: 0; order: 3; width: 100%; }
  .container { padding: 1.25rem 1rem; }
  .field-row { grid-template-columns: 1fr; }
  .auth-card { padding: 2rem 1.5rem; }
  .user-info { display: none; }
  .file-row { padding: 0.85rem 1rem; }
  .file-name { font-size: 0.9rem; }
}

/* ---------- Local-account admin UI (accounts + settings) ---------- */
.alert-success {
  background: rgba(60, 179, 113, 0.12);
  border-color: rgba(60, 179, 113, 0.35);
  color: #b7f0cf;
}
.alert-warn {
  background: rgba(240, 116, 42, 0.12);
  border-color: rgba(240, 116, 42, 0.35);
  color: #ffd0ac;
}
.alert-success a, .alert-warn a { color: inherit; text-decoration: underline; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 0.25rem 1.25rem;
  margin-bottom: 1rem;
}
.account-form .field { margin-bottom: 0.9rem; }
.field-check {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding-top: 1.6rem;
}
.field-check input { width: auto; }
.field-check .field-label { margin: 0; }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
}
.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--primary-light);
  color: var(--text);
}
.btn-danger {
  background: rgba(224, 75, 75, 0.14);
  color: #ff9a9a;
  border: 1px solid rgba(224, 75, 75, 0.4);
}
.btn-danger:hover {
  background: rgba(224, 75, 75, 0.24);
  color: #ffbcbc;
  border-color: rgba(224, 75, 75, 0.6);
}

.row-actions summary { list-style: none; cursor: pointer; display: inline-flex; }
.row-actions summary::-webkit-details-marker { display: none; }
.row-actions-panel {
  margin-top: 0.75rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  min-width: 260px;
}
.stacked-form { margin-bottom: 0.75rem; }
.stacked-form .field { margin-bottom: 0.6rem; }
.row-actions-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.row-actions-buttons .inline-form { margin: 0; }

/* ---------- Add-user form: wide email, narrow role ---------- */
.create-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 0.25rem 1.25rem;
  align-items: end;
}
@media (max-width: 760px) {
  .create-grid > * { grid-column: 1 / -1 !important; }
}

/* ---------- Sortable table headers ---------- */
.sortable-table th.is-sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.sortable-table th.is-sortable:hover { color: var(--text); }
.sortable-table th.is-sortable::after {
  content: '\2304';           /* down chevron: sortable but inactive */
  opacity: 0.4;
  margin-left: 0.45em;
  font-size: 1.4em;
  font-weight: 900;
  line-height: 1;
  vertical-align: -0.05em;
}
.sortable-table th[aria-sort="ascending"]::after  { content: '\2303'; opacity: 1; } /* up chevron */
.sortable-table th[aria-sort="descending"]::after { content: '\2304'; opacity: 1; } /* down chevron */

/* ---------- Accounts: full-width edit row under a user row ---------- */
.edit-row > td { padding: 0; background: rgba(0, 0, 0, 0.18); }
.edit-panel { padding: 1rem 1.25rem; border-top: 2px solid var(--primary-light); }
.edit-form {
  display: grid;
  grid-template-columns: minmax(240px, 2.2fr) minmax(160px, 1.4fr) 130px auto;
  gap: 0.25rem 1rem;
  align-items: end;
  margin-bottom: 0.85rem;
}
.edit-form .field { margin-bottom: 0; }
.edit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}
.edit-actions .inline-form { margin: 0; }
@media (max-width: 760px) {
  .edit-form { grid-template-columns: 1fr; }
}

/* ---------- User upload (Upload folder) ---------- */
.upload-form {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 0.85rem 1rem;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.upload-field { flex: 1 1 320px; }
.upload-field .field-label { display: block; }
.upload-field input[type="file"] {
  width: 100%;
  color: var(--text-dim);
  font-size: 0.9rem;
}
.upload-field input[type="file"]::file-selector-button {
  margin-right: 0.75rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
}
.upload-field input[type="file"]::file-selector-button:hover {
  border-color: var(--primary-light);
  background: var(--surface-hover);
}
.upload-hint { color: var(--text-muted); font-size: 0.82rem; align-self: center; }

/* ---------- Manage files: per-row move control ---------- */
.row-move-form {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0.25rem 0 0;
  flex: 0 0 auto;
}
.row-move-form select {
  max-width: 190px;
  padding: 0.4rem 0.6rem;
  font-size: 0.82rem;
  background-color: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
}
.row-move-form select:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(107, 116, 217, 0.18);
}
@media (max-width: 640px) {
  .row-move-form select { max-width: 120px; }
}

/* ---------- Manage files: per-folder icon picker ---------- */
.row-icon-form {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0.25rem 0 0;
  flex: 0 0 auto;
}
.row-icon-form select {
  max-width: 170px;
  padding: 0.4rem 0.6rem;
  font-size: 0.82rem;
  background-color: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
}
/* Solid, high-contrast option list (translucent bg made the popup hard to read). */
.row-icon-form option,
.row-move-form option {
  background-color: #1c2148;
  color: #e8eaf5;
}
/* Current icon shown to the right of the dropdown (explicit size, cache-proof). */
.row-icon-preview {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex: 0 0 auto;
}
.row-icon-form select:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(107, 116, 217, 0.18);
}
@media (max-width: 640px) { .row-icon-form select { max-width: 110px; } }

/* ---------- Folder icon popout (visual grid) ---------- */
/* Closed popouts stay static so the "Icon" buttons of rows below can't paint
   over an open panel. Only the open one is positioned + lifted into a high
   stacking context, so its panel sits above everything beneath it. */
.icon-pop { position: static; display: flex; align-items: center; flex: 0 0 auto; margin: 0 0.25rem 0 0; }
.icon-pop[open] { position: relative; z-index: 100; }
.icon-pop > summary { list-style: none; cursor: pointer; }
.icon-pop > summary::-webkit-details-marker { display: none; }
.icon-pop-toggle { display: inline-flex; align-items: center; gap: 0.4rem; }
.icon-pop-current { display: inline-flex; color: var(--accent); }
.icon-pop-current svg { display: block; }
.icon-pop-panel {
  position: absolute;
  z-index: 100;
  top: calc(100% + 6px);
  right: 0;
  width: 320px;
  max-height: 340px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 10px;
  background-color: #171b3d; /* solid, opaque — not see-through */
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}
.icon-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 9px 4px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text-dim);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.icon-choice:hover { background: var(--surface-hover); color: var(--accent); border-color: var(--border); }
.icon-choice.is-current { color: var(--accent); border-color: var(--accent); background: rgba(240, 116, 42, 0.10); }
.icon-choice svg { width: 22px; height: 22px; }
.icon-choice-label { font-size: 0.66rem; line-height: 1.15; text-align: center; word-break: break-word; }
@media (max-width: 560px) {
  .icon-pop-panel { width: 244px; grid-template-columns: repeat(3, 1fr); }
}

/* ---------- Manage files: per-row rename ---------- */
.row-rename-form {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0.25rem 0 0;
  flex: 0 0 auto;
}
.row-rename-form input[type="text"] {
  max-width: 170px;
  padding: 0.4rem 0.6rem;
  font-size: 0.82rem;
  background-color: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
}
.row-rename-form input[type="text"]:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(107, 116, 217, 0.18);
}
@media (max-width: 640px) { .row-rename-form input[type="text"] { max-width: 110px; } }

/* ---------- Accounts: text filter ---------- */
.table-filter {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1rem;
}
.table-filter input[type="search"] {
  flex: 1 1 auto;
  max-width: 360px;
  padding: 0.6rem 0.9rem;
  font-size: 0.9rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: inherit;
}
.table-filter input[type="search"]::placeholder { color: var(--text-muted); }
.table-filter input[type="search"]:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(107, 116, 217, 0.18);
}
.table-filter-count { color: var(--text-muted); font-size: 0.85rem; }
tr.filtered-out { display: none !important; }

/* ---------- Login: larger forgot-password link ---------- */
.auth-forgot { font-size: 1rem; margin-top: 1.75rem; }
.auth-forgot a { font-weight: 600; }

/* ---------- Settings: SSH/SCP example block ---------- */
.ssh-example {
  margin: 0.35rem 0 0.75rem;
  padding: 0.85rem 1rem;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-dim);
  font-family: ui-monospace, "SF Mono", Menlo, Monaco, monospace;
  font-size: 0.82rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
  overflow-x: auto;
}

/* ---------- Login notice: clean two-line layout ---------- */
.login-notice p { margin: 0; }
.login-notice p + p { margin-top: 0.5rem; }
.login-notice a { font-weight: 600; }
.nowrap { white-space: nowrap; }

/* =====================================================================
   Service desk
   Everything above is the shared Micro Connect portal theme; the rules
   below add the ticketing UI and swap the brand mark for the white
   Service Desk lockup (no white tile needed on the dark background).
   ===================================================================== */

/* ---------- Brand: white lockup, no tile ---------- */
.brand-logo {
  height: 44px;
  width: auto;
  background: none;
  padding: 0;
  border-radius: 0;
  box-shadow: none;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.35));
}
.auth-logo-desk {
  width: 240px;
  background: none;
  padding: 0;
  border-radius: 0;
  box-shadow: none;
  filter: drop-shadow(0 6px 24px rgba(107, 116, 217, 0.25));
}
.auth-card-wide { max-width: 560px; }
.auth-wrap-inpage { min-height: calc(100vh - 80px); }
.auth-alt {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
}
.auth-alt p { margin: 0.35rem 0; }
.auth-alt .inline-form { margin-top: 0.75rem; }
.auth-hint form, form.auth-hint { display: flex; align-items: center; justify-content: center; gap: 0.5rem; flex-wrap: wrap; }

/* ---------- Layout helpers ---------- */
.container-narrow { max-width: 860px; }
.page-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.form-section {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 1rem;
  color: var(--text);
}
.card > .form-section:first-child { margin-top: 0; }
.card .form-section + .page-sub { margin-top: -0.6rem; margin-bottom: 1rem; }
.form-actions { display: flex; align-items: center; gap: 0.85rem; flex-wrap: wrap; margin-top: 0.5rem; }
.field textarea { min-height: 120px; resize: vertical; line-height: 1.55; }
.field-inline { display: flex; align-items: center; gap: 0.6rem; margin: 0; }
.field-inline .field-label { margin: 0; white-space: nowrap; }
.field-inline select { width: auto; padding: 0.55rem 2rem 0.55rem 0.9rem; }
.field-check-tight { padding-top: 0; margin-bottom: 1rem; }
.field select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%239196b8' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  padding-right: 2.4rem;
}
.field select option { background: var(--surface-2); color: var(--text); }
.btn-lg { padding: 0.95rem 2rem; font-size: 1.05rem; }
.pill-orange { background: rgba(240, 116, 42, 0.14); color: #ffb385; border-color: rgba(240, 116, 42, 0.32); }

/* ---------- Home ---------- */
.home-hero { text-align: center; padding: 2.5rem 1rem 2rem; }
.home-logo {
  width: min(420px, 80vw);
  height: auto;
  margin: 0 auto 1.5rem;
  display: block;
  filter: drop-shadow(0 10px 40px rgba(107, 116, 217, 0.25));
}
.home-tag {
  max-width: 560px;
  margin: 0 auto 1.75rem;
  color: var(--text-dim);
  font-size: 1.05rem;
  line-height: 1.6;
}
.home-actions { display: flex; gap: 0.85rem; justify-content: center; flex-wrap: wrap; }
.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin: 2.5rem 0 2rem;
}
.home-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.2s ease;
}
.home-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary-light);
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(107, 116, 217, 0.2);
  color: var(--text);
}
.home-card h2 { margin: 0 0 0.4rem; font-size: 1.05rem; }
.home-card p { margin: 0; color: var(--text-dim); font-size: 0.9rem; line-height: 1.55; }
.home-card-link { color: var(--accent); font-weight: 600; }
.home-card-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: rgba(107, 116, 217, 0.14);
  border: 1px solid rgba(107, 116, 217, 0.3);
  color: var(--primary-light);
  margin-bottom: 1rem;
}
.home-card-icon svg { width: 22px; height: 22px; }
.home-foot { text-align: center; color: var(--text-muted); font-size: 0.82rem; }
.home-foot a { color: var(--text-dim); }
.home-foot a:hover { color: var(--accent); }

/* ---------- Raise a request ---------- */
.ticket-form { padding: 1.75rem; }
.who-strip {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.35rem 1rem;
  padding: 0.85rem 1rem;
  margin-bottom: 1.25rem;
  background: rgba(107, 116, 217, 0.1);
  border: 1px solid rgba(107, 116, 217, 0.25);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
}
.who-name { font-weight: 600; }
.who-email, .who-extra { color: var(--text-dim); }
.optional-account {
  margin: 0.25rem 0 1.25rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
}
.optional-account > summary { list-style: none; cursor: pointer; }
.optional-account > summary::-webkit-details-marker { display: none; }
.optional-account .field-check { padding-top: 0; }
.optional-account .field-check .field-label { text-transform: none; letter-spacing: 0; font-size: 0.92rem; color: var(--text); }
.optional-account[open] > summary { margin-bottom: 0.5rem; }
.optional-account .page-sub { font-size: 0.85rem; margin-bottom: 0.9rem; }

/* ---------- Ticket tables ---------- */
.ticket-table td { vertical-align: top; }
.ticket-ref {
  font-family: ui-monospace, "SF Mono", Menlo, Monaco, monospace;
  font-weight: 600;
  color: var(--primary-light);
  white-space: nowrap;
}
.ticket-subject { display: block; color: var(--text); font-weight: 600; }
.ticket-subject:hover { color: var(--accent); }
.ticket-cat { display: block; color: var(--text-muted); font-size: 0.78rem; margin-top: 0.15rem; }
.row-attention td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.table-legend { margin-top: 0.75rem; font-size: 0.8rem; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--accent); vertical-align: -1px; margin-right: 0.35rem; }
.queue-tools { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.queue-tools .activity-filters { margin-bottom: 0; }
.filter-count { opacity: 0.7; font-weight: 400; margin-left: 0.2rem; }
.queue-search { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.queue-search input[type="search"] {
  width: 300px; max-width: 70vw;
  padding: 0.55rem 0.9rem;
  font-size: 0.9rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text);
  font-family: inherit;
}
.queue-search input[type="search"]::placeholder { color: var(--text-muted); }
.queue-search input[type="search"]:focus { outline: none; border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(107, 116, 217, 0.18); }

/* ---------- Ticket page ---------- */
.ticket-crumbs { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.4rem; display: flex; gap: 0.5rem; align-items: center; }
.ticket-crumbs a { color: var(--text-dim); }
.ticket-crumbs a:hover { color: var(--accent); }
.ticket-title { font-size: 1.45rem; margin: 0 0 0.5rem; font-weight: 700; letter-spacing: -0.015em; overflow-wrap: anywhere; }
.ticket-metaline { display: flex; flex-wrap: wrap; gap: 0.5rem 0.65rem; align-items: center; }
.ticket-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.5rem; align-items: start; }
.ticket-side .card { padding: 1.25rem; margin-bottom: 1rem; }
.side-head { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); margin: 0 0 0.85rem; font-weight: 600; }
.side-note { font-size: 0.8rem; margin-top: 0.75rem; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 0.45rem 1rem; margin: 0; font-size: 0.88rem; }
.kv dt { color: var(--text-muted); white-space: nowrap; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.reply-card, .note-card { padding: 1.5rem; }
.reply-card .field, .note-card .field { margin-bottom: 0.85rem; }
.closed-card { text-align: center; padding: 2rem; }

/* ---------- Conversation thread ---------- */
.thread { display: flex; flex-direction: column; gap: 0.85rem; margin-bottom: 1.5rem; }
.msg {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
}
.msg-customer { border-left: 3px solid var(--primary-light); }
.msg-agent { border-left: 3px solid var(--accent); background: linear-gradient(180deg, rgba(240, 116, 42, 0.06), transparent 60%), var(--surface); }
.msg-note { border-left: 3px solid #facc15; background: rgba(234, 179, 8, 0.06); border-style: dashed; }
.msg-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.35rem 0.75rem; margin-bottom: 0.6rem; font-size: 0.85rem; }
.msg-who { font-weight: 700; color: var(--text); }
.msg-tag { color: var(--text-muted); }
.msg-agent .msg-tag { color: var(--accent); font-weight: 600; }
.msg-tag-note { color: #facc15; }
.msg-when { margin-left: auto; color: var(--text-muted); font-size: 0.78rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; font-size: 0.95rem; }
.msg-system {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.5rem;
  padding: 0.35rem 0.75rem;
  color: var(--text-dim);
  font-size: 0.82rem;
}
.msg-system .msg-who { font-size: 0.85rem; }

/* ---------- Error page ---------- */
.error-mark { width: 72px; height: auto; margin: 0 auto 1rem; display: block; opacity: 0.9; }
.error-actions { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; margin-top: 1.25rem; }

/* ---------- Accounts: 4-column edit form ---------- */
.edit-form-4 { grid-template-columns: minmax(220px, 2fr) minmax(160px, 1.4fr) minmax(140px, 1.2fr) 120px auto; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .ticket-layout { grid-template-columns: 1fr; }
  .edit-form-4 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .brand-logo { height: 36px; }
  .msg-when { margin-left: 0; width: 100%; }
  .ticket-form { padding: 1.25rem; }
  .queue-search input[type="search"] { width: 100%; max-width: none; }
  .queue-search { width: 100%; }
}

/* ---------- Attachments ---------- */
.attach-field input[type="file"] {
  width: 100%;
  padding: 0.6rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-dim);
  font-size: 0.9rem;
  cursor: pointer;
}
.attach-field input[type="file"]::file-selector-button {
  margin-right: 0.85rem;
  padding: 0.45rem 0.95rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}
.attach-field input[type="file"]::file-selector-button:hover { background: var(--surface-hover); border-color: var(--primary-light); }
.attach-hint { margin: 0.5rem 0 0; color: var(--text-muted); font-size: 0.8rem; }
.attach-hint-error { color: #ffb8b8; }
.attach-list { list-style: none; margin: 0.9rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.attach-chip {
  display: inline-flex; align-items: center; gap: 0.45rem;
  max-width: 100%;
  padding: 0.4rem 0.8rem;
  background: rgba(107, 116, 217, 0.1);
  border: 1px solid rgba(107, 116, 217, 0.3);
  border-radius: var(--radius-pill);
  color: var(--text);
  font-size: 0.82rem;
  transition: border-color 0.15s, background 0.15s;
}
.attach-chip:hover { border-color: var(--accent); background: rgba(240, 116, 42, 0.1); color: var(--text); }
.attach-chip svg { width: 15px; height: 15px; flex: none; color: var(--primary-light); }
.attach-chip:hover svg { color: var(--accent); }
.attach-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.attach-size { color: var(--text-muted); white-space: nowrap; }

/* ---------- Honeypot (anti-bot) field: off-screen, never shown ---------- */
.hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }
