/* Dawra dashboard — bento, system font, light/dark, subtle motion */

:root {
  --bg: #f5f5f7;
  --tile: #ffffff;
  --tile-2: #f5f5f7;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #86868b;
  --sep: rgba(0, 0, 0, 0.08);
  --blue: #0071e3;
  --blue-soft: rgba(0, 113, 227, 0.1);
  --green: #28a745;
  --green-soft: rgba(52, 199, 89, 0.14);
  --orange: #f08c00;
  --orange-soft: rgba(255, 159, 10, 0.16);
  --red: #e5332a;
  --red-soft: rgba(255, 59, 48, 0.12);
  --purple: #8e44d6;
  --purple-soft: rgba(175, 82, 222, 0.12);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.04);
  --glass: rgba(245, 245, 247, 0.72);
  --scrim: rgba(0, 0, 0, 0.18);
  --radius: 22px;
  --radius-sm: 12px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1); /* Apple sheet curve */
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --tile: #1c1c1e;
    --tile-2: #2c2c2e;
    --text: #f5f5f7;
    --text-2: #98989d;
    --text-3: #7c7c80;
    --sep: rgba(255, 255, 255, 0.1);
    --blue: #0a84ff;
    --blue-soft: rgba(10, 132, 255, 0.18);
    --green: #30d158;
    --green-soft: rgba(48, 209, 88, 0.16);
    --orange: #ff9f0a;
    --orange-soft: rgba(255, 159, 10, 0.18);
    --red: #ff453a;
    --red-soft: rgba(255, 69, 58, 0.16);
    --purple: #bf5af2;
    --purple-soft: rgba(191, 90, 242, 0.16);
    --shadow: none;
    --glass: rgba(0, 0, 0, 0.66);
    --scrim: rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.47 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; letter-spacing: inherit; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; letter-spacing: 0; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- header */

.bar {
  position: sticky; top: 0; z-index: 20;
  background: var(--glass);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--sep);
}
.bar-in {
  max-width: 1240px; margin: 0 auto; padding: 0 16px;
  height: 52px; display: flex; align-items: center; gap: 12px;
}
.brand { font-weight: 600; font-size: 17px; letter-spacing: -0.02em; }
.live { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-2); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex: none; }
.dot.off { background: var(--text-3); }
.dot.pulse { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }
.spacer { flex: 1; }

/* ---------------------------------------------------------------- bento */

main { max-width: 1240px; margin: 0 auto; padding: 20px 16px 48px; }
.grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .grid { grid-template-columns: repeat(6, 1fr); } }
@media (min-width: 1080px) { .grid { grid-template-columns: repeat(12, 1fr); } }

.tile {
  background: var(--tile);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  min-width: 0;
  display: flex; flex-direction: column;
}
@media (min-width: 760px) {
  .s-6 { grid-column: span 6; } .s-3 { grid-column: span 3; }
}
@media (min-width: 1080px) {
  .l-8 { grid-column: span 8; } .l-4 { grid-column: span 4; } .l-12 { grid-column: span 12; }
}

.t-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; min-height: 28px; }
.t-title { font-size: 13px; font-weight: 600; color: var(--text-2); letter-spacing: 0; }
.t-head .spacer { flex: 1; }

.big {
  font-size: 44px; line-height: 1; font-weight: 600; letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}
.mid { font-size: 28px; line-height: 1.05; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.label { font-size: 13px; color: var(--text-2); margin-top: 4px; }

/* ---------------------------------------------------------------- controls */

.btn {
  appearance: none; border: 0; cursor: pointer;
  height: 34px; padding: 0 14px; border-radius: 980px;
  background: var(--tile-2); color: var(--text);
  font-size: 14px; font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: transform 100ms ease-out, background-color 150ms ease, opacity 150ms ease;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; white-space: nowrap;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.4; cursor: default; transform: none; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.ghost { background: transparent; color: var(--blue); padding: 0 8px; }
.btn.icon { width: 34px; padding: 0; font-size: 18px; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.icon.sm { width: 28px; padding: 0; }
.btn:focus-visible, .field:focus-visible, .switch input:focus-visible + span {
  outline: 3px solid var(--blue-soft); outline-offset: 1px;
}

.field {
  height: 34px; border-radius: 10px; border: 1px solid var(--sep);
  background: var(--tile-2); padding: 0 10px; min-width: 0; outline: none;
  font-variant-numeric: tabular-nums;
}
.field:focus { border-color: var(--blue); }

.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }

.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span {
  width: 36px; height: 22px; border-radius: 11px; background: var(--tile-2);
  border: 1px solid var(--sep); position: relative; transition: background-color 200ms ease;
}
.switch span::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 250ms var(--ease);
}
.switch input:checked + span { background: var(--green); border-color: transparent; }
.switch input:checked + span::after { transform: translateX(14px); }

/* stepper for X */
.stepper { display: inline-flex; align-items: center; gap: 4px; background: var(--tile-2); border-radius: 980px; padding: 3px; }
.stepper .btn { background: var(--tile); height: 30px; width: 30px; font-size: 18px; box-shadow: var(--shadow); }
.stepper output { min-width: 32px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.steppers { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.step-lbl { font-size: 12px; font-weight: 600; color: var(--muted); padding: 0 4px 0 8px; letter-spacing: .02em; }

input[type="range"] { width: 100%; accent-color: var(--blue); margin: 0; }

/* ---------------------------------------------------------------- pills */

.pill {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px;
  border-radius: 980px; font-size: 12px; font-weight: 500; white-space: nowrap;
  background: var(--tile-2); color: var(--text-2);
}
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.orange { background: var(--orange-soft); color: var(--orange); }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.blue { background: var(--blue-soft); color: var(--blue); }
.pill.purple { background: var(--purple-soft); color: var(--purple); }

/* ---------------------------------------------------------------- agent workers */

.notice {
  display: flex; align-items: center; gap: 8px; font-size: 13px;
  background: var(--blue-soft); color: var(--blue); border-radius: var(--radius-sm);
  padding: 8px 12px; margin-bottom: 12px;
}
.slots { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.slot {
  border-radius: 16px; background: var(--tile-2); padding: 12px; min-height: 92px;
  display: flex; flex-direction: column; gap: 6px; position: relative;
  animation: rise 360ms var(--ease) both;
}
.slot.idle { background: transparent; border: 1.5px dashed var(--sep); justify-content: center; align-items: center; color: var(--text-3); font-size: 13px; animation: none; }
.slot.over { opacity: 0.6; }
.slot .k { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.slot .who { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot .time { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; margin-top: auto; }
.slot .x { position: absolute; top: 8px; right: 8px; }
.slot-n { font-size: 11px; color: var(--text-3); font-weight: 500; }
.kind-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.kind-dot.login { background: var(--blue); }
.kind-dot.warm { background: var(--orange); }
@keyframes rise { from { opacity: 0; transform: translateY(6px) scale(0.98); } }

/* ---------------------------------------------------------------- stats */

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px 12px; }
.stat .mid.green { color: var(--green); } .stat .mid.red { color: var(--red); }
.stat .mid.orange { color: var(--orange); } .stat .mid.blue { color: var(--blue); }

.meter { height: 6px; border-radius: 3px; background: var(--tile-2); overflow: hidden; display: flex; margin: 14px 0 4px; }
.meter i { display: block; height: 100%; transition: width 500ms var(--ease); }
.meter .g { background: var(--green); } .meter .o { background: var(--orange); }
.meter .r { background: var(--red); } .meter .b { background: var(--blue); }

/* ---------------------------------------------------------------- lists */

.list { display: flex; flex-direction: column; }
.li {
  display: flex; align-items: center; gap: 10px; padding: 10px 2px;
  border-top: 1px solid var(--sep); min-height: 48px;
}
.li:first-child { border-top: 0; }
.li .grow { flex: 1; min-width: 0; }
.li .t1 { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li .t2 { font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li.click { cursor: pointer; border-radius: 10px; transition: background-color 150ms ease; margin: 0 -8px; padding-left: 10px; padding-right: 10px; }
.li.click:hover { background: var(--tile-2); }
.li.click:active { background: var(--sep); }
.li.click + .li { border-top-color: var(--sep); }
.chev { color: var(--text-3); font-size: 18px; }
.empty { color: var(--text-3); font-size: 13px; padding: 18px 0; text-align: center; }

.seg { display: inline-flex; background: var(--tile-2); border-radius: 9px; padding: 2px; gap: 2px; }
.seg button {
  border: 0; background: transparent; height: 26px; padding: 0 10px; border-radius: 7px;
  font-size: 12px; font-weight: 500; color: var(--text-2); cursor: pointer;
}
.seg button.on { background: var(--tile); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }

.scroll { overflow: auto; max-height: 460px; margin: 0 -8px; padding: 0 8px; }

/* ---------------------------------------------------------------- files */

.file { position: relative; }
.file.drag { background: var(--blue-soft); border-radius: 10px; }
.file input[type="file"] { display: none; }
.hint { font-size: 12px; color: var(--text-3); margin-top: 10px; }

.drop {
  display: flex; align-items: center; gap: 12px; padding: 14px; margin-bottom: 6px;
  border: 1.5px dashed var(--sep); border-radius: 16px; cursor: pointer;
  font-size: 13px; line-height: 1.4; color: var(--text-2);
  transition: background-color 150ms ease, border-color 150ms ease, transform 100ms ease-out;
}
.drop b { color: var(--text); font-weight: 600; }
.drop:hover { background: var(--tile-2); }
.drop:active { transform: scale(0.99); }
.drop:focus-visible { outline: 3px solid var(--blue-soft); }
.drop.over, body.dragging .drop { border-color: var(--blue); background: var(--blue-soft); }
.drop input { display: none; }
.drop-icon {
  flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--blue-soft); color: var(--blue); font-size: 17px; font-weight: 600;
}

/* ---------------------------------------------------------------- modal */

.modal {
  border: 0; padding: 0; margin: auto; width: min(480px, calc(100vw - 32px));
  background: var(--tile); color: inherit; border-radius: 20px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.22), 0 2px 8px rgba(0, 0, 0, 0.08);
}
.modal[open] { animation: modal-in 220ms cubic-bezier(0.2, 0.9, 0.3, 1); }
.modal.closing { animation: modal-out 160ms ease-in forwards; }
.modal::backdrop { background: var(--scrim, rgba(0, 0, 0, 0.3)); animation: fade-in 220ms ease; }
.modal.closing::backdrop { animation: fade-out 160ms ease-in forwards; }
@keyframes modal-in { from { opacity: 0; transform: scale(0.96) translateY(8px); } }
@keyframes modal-out { to { opacity: 0; transform: scale(0.97); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
.modal-in { display: flex; flex-direction: column; gap: 14px; padding: 20px; }
.modal-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 2px; }
.modal-in label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--text-2); }
.modal-in .field { width: 100%; }
.modal-foot { justify-content: flex-end; margin-top: 4px; }

/* ---------------------------------------------------------------- activity */

.feed {
  max-height: 280px; overflow: auto; background: var(--tile-2); border-radius: 14px;
  padding: 10px 12px; line-height: 1.7; white-space: pre-wrap; word-break: break-word;
}
.feed .e { color: var(--red); } .feed .w { color: var(--orange); }

/* ---------------------------------------------------------------- sheet (profile detail) */

.scrim {
  position: fixed; inset: 0; background: var(--scrim); z-index: 40;
  opacity: 0; transition: opacity 300ms ease; pointer-events: none;
}
.scrim.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 41;
  width: min(560px, 100vw); background: var(--tile);
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.12);
  transform: translateX(104%); transition: transform 420ms var(--ease);
  display: flex; flex-direction: column;
}
.sheet.open { transform: none; }
.sheet-head {
  padding: 16px 16px 12px; display: flex; align-items: flex-start; gap: 10px;
  border-bottom: 1px solid var(--sep);
}
.sheet-body { overflow: auto; padding: 16px; flex: 1; }
.facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 18px; }
.fact { background: var(--tile-2); border-radius: 12px; padding: 10px 12px; }
.fact b { display: block; font-size: 12px; font-weight: 500; color: var(--text-2); }
.fact span { font-size: 14px; font-weight: 500; }
.h3 { font-size: 13px; font-weight: 600; color: var(--text-2); margin: 18px 0 8px; }

.shots { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.shots a { flex: none; width: 150px; border-radius: 10px; overflow: hidden; border: 1px solid var(--sep); background: var(--tile-2); }
.shots img { display: block; width: 100%; height: 94px; object-fit: cover; object-position: top; }
.shots small { display: block; font-size: 11px; color: var(--text-2); padding: 4px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.timeline { position: relative; }
.job-h { font-size: 12px; font-weight: 600; color: var(--text-2); margin: 14px 0 6px; display: flex; gap: 8px; align-items: center; }
.ev { display: grid; grid-template-columns: 58px 1fr; gap: 8px; padding: 5px 0; font-size: 13px; border-top: 1px solid var(--sep); }
.ev time { color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; padding-top: 1px; }
.ev .m { min-width: 0; overflow-wrap: anywhere; }
.ev .d { display: block; font-size: 11.5px; color: var(--text-3); margin-top: 1px; }
.ev.warn .m { color: var(--orange); }
.ev.error .m { color: var(--red); }
.ev details { margin-top: 4px; }
.ev pre { font-size: 11px; white-space: pre-wrap; background: var(--tile-2); padding: 8px; border-radius: 8px; margin: 4px 0 0; }

/* ---------------------------------------------------------------- toast */

.toasts { position: fixed; left: 0; right: 0; bottom: 20px; z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast {
  background: var(--glass); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  color: var(--text); border: 1px solid var(--sep); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  border-radius: 14px; padding: 10px 16px; font-size: 14px; max-width: 520px;
  animation: toast-in 380ms var(--ease) both;
}
.toast.err { color: var(--red); }
.toast.out { animation: toast-out 220ms ease both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* ---------------------------------------------------------------- sign-in page */

.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: min(360px, 100%); background: var(--tile); border-radius: 26px; box-shadow: var(--shadow); padding: 32px 24px 24px; text-align: center; }
.auth-card h1 { font-size: 28px; letter-spacing: -0.03em; margin: 8px 0 4px; }
.auth-card p { margin: 0 0 22px; color: var(--text-2); font-size: 14px; }
.auth-card .field { width: 100%; height: 44px; font-size: 16px; text-align: center; border-radius: 12px; }
.auth-card .btn { width: 100%; height: 44px; margin-top: 12px; font-size: 16px; }
.auth-err { color: var(--red); font-size: 13px; min-height: 20px; margin-top: 10px; }
.logo {
  width: 56px; height: 56px; border-radius: 15px; margin: 0 auto;
  background: linear-gradient(145deg, #5e5ce6, #0a84ff); display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 24px; letter-spacing: -0.04em;
  box-shadow: 0 6px 18px rgba(10, 132, 255, 0.3);
}

/* ---------------------------------------------------------------- accessibility */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; }
  .sheet { transition: opacity 200ms ease; transform: none; opacity: 0; pointer-events: none; }
  .sheet.open { opacity: 1; pointer-events: auto; }
  .btn:active { transform: none; }
  .modal[open], .modal.closing { animation-name: fade-in; }
  .modal.closing { animation-name: fade-out; }
}
@media (prefers-reduced-transparency: reduce) {
  .bar, .toast { background: var(--tile); backdrop-filter: none; -webkit-backdrop-filter: none; }
}

/* ---------------------------------------------------------------- wide screens: fill the window, no page scroll
   Big monitors use the full width and fit in one screen; long lists scroll inside their own tile. */

@media (min-width: 1440px) and (min-height: 760px) {
  .bar-in { max-width: none; padding: 0 24px; }
  main { max-width: none; padding: 16px 24px; height: calc(100dvh - 53px); }
  .grid {
    height: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.3fr);
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas:
      "workers  workers  sessions profiles"
      "warm     login    queue    profiles"
      "files    activity activity profiles";
  }
  .grid > #a-workers { grid-area: workers; }
  .grid > #a-sessions { grid-area: sessions; }
  .grid > #a-warm { grid-area: warm; }
  .grid > #a-login { grid-area: login; }
  .grid > #a-queue { grid-area: queue; }
  .grid > #a-profiles { grid-area: profiles; }
  .grid > #a-files { grid-area: files; }
  .grid > #a-activity { grid-area: activity; }

  .tile { min-height: 0; }
  /* lists take the tile's remaining height and scroll inside it */
  #a-profiles .scroll, #a-queue .scroll, #a-files .list { flex: 1; min-height: 0; max-height: none; overflow: auto; }
  #a-queue .scroll { max-height: none !important; }
  #a-files .list { margin: 0 -8px; padding: 0 8px; }
  #a-activity .feed { flex: 1; min-height: 0; max-height: none; }
  #a-files .hint { display: none; }

  /* compact agent worker cards so 8+ fit in two short rows */
  .slots { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
  .slot { min-height: 74px; padding: 10px 12px; gap: 4px; }
}

/* very wide (2560+): a little more air */
@media (min-width: 2200px) and (min-height: 760px) {
  main, .bar-in { padding-left: 40px; padding-right: 40px; }
  .grid { gap: 20px; }
}
