/* ===========================================================================
   Office Loader — Admin panel styles
   =========================================================================== */

:root {
  --bg: #0a0d14;
  --bg-grad-1: #12141f;
  --bg-grad-2: #0a0d14;
  --surface: #121622;
  --surface-2: #181d2b;
  --surface-3: #1f2535;
  --border: #232a3a;
  --border-soft: #1b2230;
  --text: #e9edf6;
  --text-2: #a4aec2;
  --text-3: #6b7689;
  --accent: #6366f1;
  --accent-2: #818cf8;
  --accent-soft: rgba(99, 102, 241, 0.16);
  --violet: #8b5cf6;
  --green: #22c55e;
  --green-soft: rgba(34, 197, 94, 0.15);
  --yellow: #f59e0b;
  --yellow-soft: rgba(245, 158, 11, 0.15);
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, 0.14);
  --cyan: #06b6d4;
  --radius: 12px;
  --radius-sm: 9px;
  --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, 0.65);
  --shadow-md: 0 10px 30px -12px rgba(0, 0, 0, 0.55);
  --mono: "Cascadia Code", "JetBrains Mono", "Consolas", "Menlo", monospace;
  --sans: "Inter", -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  background-image:
    radial-gradient(1000px 500px at 12% -8%, rgba(99, 102, 241, 0.10), transparent 60%),
    radial-gradient(900px 500px at 95% -10%, rgba(139, 92, 246, 0.08), transparent 55%);
  background-attachment: fixed;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--text-3); }
.spacer { flex: 1; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2a3346; border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #37415a; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

button { font-family: inherit; }
input, select { font-family: inherit; }

svg { flex-shrink: 0; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 9px 16px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s, box-shadow .15s, color .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--violet));
  color: #fff; box-shadow: 0 8px 20px -8px rgba(99, 102, 241, 0.55);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 10px 26px -8px rgba(99, 102, 241, 0.7); filter: brightness(1.06); }
.btn-ghost { background: var(--surface-2); color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { color: var(--text); border-color: #33405a; background: var(--surface-3); }
.btn-ghost.active { color: var(--accent-2); border-color: var(--accent); background: var(--accent-soft); }
.btn-danger { background: transparent; color: var(--red); border-color: rgba(239, 68, 68, 0.4); }
.btn-danger:hover:not(:disabled) { background: var(--red-soft); border-color: var(--red); }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn-block { width: 100%; }
.link-btn { background: none; border: none; color: var(--accent-2); font-size: 12px; cursor: pointer; padding: 0; }
.link-btn:hover { text-decoration: underline; }

/* ---- Inputs ---- */
input[type=text], input[type=password], select {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 9px 12px; outline: none; font-size: 13.5px;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
input::placeholder { color: var(--text-3); }
input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }

/* ---- Search ---- */
.search {
  position: relative; display: flex; align-items: center;
}
.search svg {
  position: absolute; left: 11px; width: 15px; height: 15px; color: var(--text-3);
  pointer-events: none;
}
.search input {
  padding-left: 34px; width: 210px; transition: width .2s;
}
.search input:focus { width: 260px; }
.search input::placeholder { color: var(--text-3); }

/* ===========================================================================
   Login
   =========================================================================== */
.login-screen {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 22px; padding: 20px;
  background: var(--bg);
}
.login-bg {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(700px 420px at 50% 18%, rgba(99, 102, 241, 0.18), transparent 60%),
    radial-gradient(600px 400px at 80% 85%, rgba(139, 92, 246, 0.12), transparent 60%),
    radial-gradient(600px 400px at 15% 80%, rgba(6, 182, 212, 0.10), transparent 60%);
}
.login-card {
  position: relative; z-index: 1;
  background: linear-gradient(180deg, rgba(24, 29, 43, 0.9), rgba(18, 22, 34, 0.92));
  border: 1px solid var(--border); border-radius: 18px; padding: 38px 34px 30px;
  width: 380px; max-width: 92vw; display: flex; flex-direction: column; gap: 16px;
  box-shadow: var(--shadow-lg); backdrop-filter: blur(8px);
}
.login-logo {
  width: 58px; height: 58px; border-radius: 16px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--violet));
  box-shadow: 0 12px 30px -10px rgba(99, 102, 241, 0.7); margin: 0 auto;
}
.login-card h1 { margin: 4px 0 0; font-size: 24px; font-weight: 700; text-align: center; letter-spacing: -0.3px; }
.login-sub { margin: 0; color: var(--text-2); text-align: center; font-size: 13.5px; }
.login-card .field { gap: 7px; }
.login-card .btn { margin-top: 4px; padding: 11px; }
.error-text { color: var(--red); min-height: 18px; font-size: 13px; text-align: center; }
.login-foot { color: var(--text-3); font-size: 12px; z-index: 1; }

/* ===========================================================================
   Topbar
   =========================================================================== */
.topbar {
  display: flex; align-items: center; gap: 22px; padding: 0 22px; height: 62px;
  background: rgba(13, 16, 24, 0.85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-soft);
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-logo {
  width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--violet));
  box-shadow: 0 6px 16px -6px rgba(99, 102, 241, 0.6);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 15px; font-weight: 700; letter-spacing: -0.2px; }
.brand-text span { font-size: 11px; color: var(--text-3); }

.nav { display: flex; gap: 4px; margin: 0 auto; }
.nav button {
  display: inline-flex; align-items: center; gap: 8px;
  background: transparent; border: none; color: var(--text-2);
  padding: 8px 14px; border-radius: 10px; cursor: pointer; font-size: 13.5px; font-weight: 500;
  transition: color .15s, background .15s; position: relative;
}
.nav button svg { width: 17px; height: 17px; }
.nav button:hover { color: var(--text); background: var(--surface-2); }
.nav button.active { color: #fff; background: var(--surface-2); }
.nav button.active::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: -1px; height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--violet)); border-radius: 2px;
}

.top-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.ws-pill {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600;
  color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border);
  padding: 6px 11px; border-radius: 20px;
}
.ws-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); transition: background .2s; }
.ws-pill.on { color: var(--green); }
.ws-pill.on .ws-dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
.ws-pill.off { color: var(--red); }
.ws-pill.off .ws-dot { background: var(--red); }

/* ===========================================================================
   Stats
   =========================================================================== */
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
  max-width: 1280px; margin: 18px auto 0; padding: 0 22px;
}
.stat-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: 16px 18px; transition: border-color .15s, transform .15s;
}
.stat-card:hover { border-color: var(--border); transform: translateY(-1px); }
.stat-icon {
  width: 44px; height: 44px; border-radius: 11px; display: flex; align-items: center; justify-content: center;
}
.stat-icon svg { width: 22px; height: 22px; }
.si-blue { background: var(--accent-soft); color: var(--accent-2); }
.si-violet { background: rgba(139, 92, 246, 0.16); color: #a78bfa; }
.si-green { background: var(--green-soft); color: var(--green); }
.si-amber { background: var(--yellow-soft); color: var(--yellow); }
.stat-meta { display: flex; flex-direction: column; line-height: 1.2; }
.stat-value { font-size: 22px; font-weight: 700; letter-spacing: -0.4px; }
.stat-total { font-size: 14px; color: var(--text-3); font-weight: 500; }
.stat-label { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* ===========================================================================
   Layout
   =========================================================================== */
main { padding: 20px 22px 60px; max-width: 1280px; margin: 0 auto; }
.tab { display: none; animation: fade .18s ease; }
.tab.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar-title { display: flex; flex-direction: column; }
.toolbar-title h2 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.2px; }
.toolbar-title span { font-size: 12.5px; color: var(--text-3); }

.pills { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border-soft); border-radius: 10px; padding: 3px; }
.pill {
  background: transparent; border: none; color: var(--text-3); padding: 5px 12px;
  border-radius: 7px; cursor: pointer; font-size: 12.5px; font-weight: 600; transition: all .15s;
}
.pill:hover { color: var(--text-2); }
.pill.active { background: var(--surface-3); color: var(--text); }

/* ===========================================================================
   Console
   =========================================================================== */
.console {
  background: #070a10; border: 1px solid var(--border-soft); border-radius: var(--radius);
  font-family: var(--mono); font-size: 12.5px; line-height: 1.65;
  height: calc(100vh - 260px); min-height: 300px; overflow-y: auto; padding: 12px 14px;
}
.console-empty {
  color: var(--text-3); text-align: center; padding: 40px; border: 1px dashed var(--border);
  border-radius: var(--radius); margin-top: 0; font-family: var(--mono); font-size: 13px;
}
.log-line { padding: 2px 4px; white-space: pre-wrap; word-break: break-word; border-radius: 5px; }
.log-line:hover { background: rgba(255, 255, 255, 0.025); }
.log-time { color: #4c5a70; }
.log-chip {
  display: inline-block; min-width: 52px; text-align: center; font-weight: 700;
  border-radius: 5px; padding: 0 5px; font-size: 11px; margin: 0 2px;
}
.log-chip.info { color: var(--green); background: var(--green-soft); }
.log-chip.warn { color: var(--yellow); background: var(--yellow-soft); }
.log-chip.error { color: var(--red); background: var(--red-soft); }
.log-host { color: var(--accent-2); }
.log-msg { color: var(--text); }
.log-job { color: var(--text-3); font-size: 11px; }

/* ===========================================================================
   Tables
   =========================================================================== */
.table-card {
  background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius);
  overflow: hidden;
}
.grid { width: 100%; border-collapse: collapse; }
.grid th, .grid td {
  text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border-soft);
  font-size: 13px; vertical-align: middle;
}
.grid thead th {
  color: var(--text-3); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.4px;
  background: var(--surface-2); border-bottom: 1px solid var(--border); position: sticky; top: 0;
}
.grid tbody tr:last-child td { border-bottom: none; }
.grid tbody tr { transition: background .12s; }
.grid tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
.th-right { text-align: right; }
.td-right { text-align: right; }
.td-actions { display: flex; gap: 6px; justify-content: flex-end; }
.cell-mono { font-family: var(--mono); font-size: 12.5px; color: var(--text-2); }
.cell-dim { color: var(--text-3); }
.cell-result { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.cell-result:hover { white-space: normal; word-break: break-word; }

/* ---- Badges ---- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px;
  border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.online { background: var(--green-soft); color: var(--green); }
.badge.offline { background: rgba(107, 118, 137, 0.16); color: var(--text-2); }
.badge.pending { background: rgba(107, 118, 137, 0.16); color: var(--text-2); }
.badge.delivered { background: var(--accent-soft); color: var(--accent-2); }
.badge.running { background: var(--yellow-soft); color: var(--yellow); }
.badge.success { background: var(--green-soft); color: var(--green); }
.badge.failed { background: var(--red-soft); color: var(--red); }

/* ---- Empty ---- */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  color: var(--text-3); padding: 44px 20px; text-align: center;
  border: 1px dashed var(--border); border-radius: var(--radius); margin-top: 12px; background: var(--surface);
}
.empty-icon {
  width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--text-3); margin-bottom: 4px;
}
.empty-icon svg { width: 26px; height: 26px; }
.empty p { margin: 0; font-size: 15px; font-weight: 600; color: var(--text-2); }
.empty span { font-size: 12.5px; }

/* ===========================================================================
   Forms
   =========================================================================== */
.field { display: flex; flex-direction: column; gap: 7px; min-width: 180px; }
.field-label { color: var(--text-2); font-size: 12px; font-weight: 600; }
.field-label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.field-grow { flex: 1 1 280px; }

/* ---- Upload ---- */
.upload-zone {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--surface); border: 1.5px dashed var(--border); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 16px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.upload-zone:hover, .upload-zone.drag { border-color: var(--accent); background: var(--accent-soft); }
.upload-icon {
  width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-2);
}
.upload-icon svg { width: 24px; height: 24px; }
.upload-copy { display: flex; flex-direction: column; line-height: 1.4; flex: 1 1 200px; }
.upload-copy strong { font-size: 14px; }
.upload-copy span { font-size: 12.5px; color: var(--text-3); }
.upload-copy u { text-decoration-color: var(--accent); color: var(--accent-2); }
.upload-status { font-size: 12.5px; color: var(--text-2); max-width: 220px; }
.upload-status.ok { color: var(--green); }
.upload-status.err { color: var(--red); }

/* ---- Job form ---- */
.job-form {
  background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 16px;
}
.job-form-head { display: flex; flex-direction: column; margin-bottom: 16px; }
.job-form-head h3 { margin: 0; font-size: 15px; font-weight: 700; }
.job-form-head span { font-size: 12.5px; color: var(--text-3); }
.job-form-grid { display: flex; flex-wrap: wrap; gap: 14px; }
.job-form-foot { margin-top: 16px; display: flex; }
.agent-checks { display: flex; flex-wrap: wrap; gap: 8px; max-height: 96px; overflow-y: auto; padding: 2px; }
.agent-checks label {
  display: inline-flex; align-items: center; gap: 7px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 12.5px;
  transition: all .15s; user-select: none;
}
.agent-checks label:hover { border-color: #33405a; }
.agent-checks label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-2); }
.agent-checks input { accent-color: var(--accent); margin: 0; }

/* ===========================================================================
   Toasts
   =========================================================================== */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 60; }
.toast {
  display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 360px;
  background: var(--surface-3); border: 1px solid var(--border); border-radius: 11px;
  padding: 12px 14px; font-size: 13px; box-shadow: var(--shadow-md); animation: toast-in .22s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
.toast.leaving { opacity: 0; transform: translateX(20px); transition: all .2s; }
.toast-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.toast.success .toast-dot { background: var(--green); }
.toast.error .toast-dot { background: var(--red); }
.toast.info .toast-dot { background: var(--accent-2); }

/* ===========================================================================
   Modal
   =========================================================================== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(5, 7, 11, 0.66); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 28px; width: 400px; max-width: 92vw; text-align: center; box-shadow: var(--shadow-lg);
  animation: toast-in .2s ease;
}
.modal-icon {
  width: 50px; height: 50px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--red-soft); color: var(--red); margin: 0 auto 14px;
}
.modal-icon svg { width: 26px; height: 26px; }
.modal h3 { margin: 0 0 6px; font-size: 17px; }
.modal p { margin: 0 0 22px; color: var(--text-2); font-size: 13.5px; }
.modal-actions { display: flex; gap: 10px; justify-content: center; }
.modal-actions .btn { min-width: 110px; }

/* ===========================================================================
   Responsive
   =========================================================================== */
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .nav { order: 3; width: 100%; justify-content: center; margin: 0; overflow-x: auto; }
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 10px; }
  .top-right { margin-left: 0; }
}
@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr; padding: 0 14px; }
  main { padding: 14px 14px 60px; }
  .search input { width: 140px; }
  .search input:focus { width: 160px; }
  .brand-text span { display: none; }
}
