/* Privatily Cloud — shared design system */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e4e7ec;
  --border-strong: #cfd4dd;
  --text: #101828;
  --muted: #667085;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --green: #067647;
  --green-bg: #e7f6ee;
  --red: #b42318;
  --red-bg: #fef3f2;
  --amber-text: #7a4d05;
  --amber-bg: #fffaeb;
  --amber-border: #f0d183;
  --sidebar-bg: #12141f;
  --sidebar-line: #232637;
  --sidebar-text: #9aa1b4;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 14.5px/1.55 var(--font); background: var(--bg); color: var(--text);
       -webkit-font-smoothing: antialiased; }

/* ---- App shell -------------------------------------------------------- */
.layout { display: flex; min-height: 100vh; }

.sidebar { width: 230px; flex-shrink: 0; background: var(--sidebar-bg); color: var(--sidebar-text);
           display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 10px; align-items: center; color: #fff; font-weight: 700; font-size: 15px;
         padding: 4px 10px 18px; letter-spacing: .2px; text-decoration: none; }
.brand .mark { width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0;
               background: linear-gradient(135deg, #6366f1, #8b5cf6); display: grid; place-items: center; }
.brand .mark svg { display: block; }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav a { display: flex; align-items: center; gap: 10px; color: var(--sidebar-text); text-decoration: none;
         padding: 9px 10px; border-radius: 8px; font-weight: 500; font-size: 13.5px;
         transition: background .15s, color .15s; }
.nav a svg { opacity: .7; flex-shrink: 0; }
.nav a:hover { background: #1d2130; color: #fff; }
.nav a.active { background: var(--accent); color: #fff; }
.nav a.active svg { opacity: 1; }
.sidebar-footer { margin-top: auto; border-top: 1px solid var(--sidebar-line); padding: 12px 4px 0;
                  display: flex; flex-direction: column; gap: 8px; }
.user-email { font-size: 12px; color: #c3c8d8; word-break: break-all; padding: 0 6px; }
.btn-signout { appearance: none; border: 1px solid var(--sidebar-line); background: transparent;
               color: var(--sidebar-text); padding: 6px 10px; border-radius: 8px; font: 600 12.5px var(--font);
               cursor: pointer; transition: all .15s; text-align: left; }
.btn-signout:hover { background: #1d2130; color: #fff; }

.main { flex: 1; min-width: 0; padding: 28px 36px 56px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px;
             margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.2px; }
.page-head .sub { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---- Cards ------------------------------------------------------------ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
        box-shadow: var(--shadow); }
.card + .card, .grid-2 + .card, .card + .grid-2 { margin-top: 20px; }
.card-head { padding: 15px 20px; border-bottom: 1px solid var(--border); display: flex;
             justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; font-size: 15px; font-weight: 650; }
.card-head .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; font-weight: 400; }
.card-body { padding: 18px 20px; }
.card-body.flush { padding: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 20px; }

/* ---- Tables ----------------------------------------------------------- */
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px;
            color: var(--muted); font-weight: 600; padding: 10px 20px; border-bottom: 1px solid var(--border);
            background: #f9fafb; }
.table th:first-child { border-top-left-radius: var(--radius); }
.table th:last-child { border-top-right-radius: var(--radius); }
.table td { padding: 10px 20px; border-bottom: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; }
.table tbody tr:hover td { background: #f9fafb; }
.table tbody tr:last-child td { border-bottom: none; }

/* ---- Controls --------------------------------------------------------- */
.btn { appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
       border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
       padding: 7px 13px; border-radius: 8px; font: 600 13px var(--font); cursor: pointer;
       transition: all .15s; white-space: nowrap; }
.btn:hover { background: #f2f4f7; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; border-radius: 7px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn:focus-visible, .input:focus-visible, .copy-btn:focus-visible, .btn-signout:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; }

.input { padding: 8px 11px; border: 1px solid var(--border-strong); border-radius: 8px;
         font: 14px var(--font); background: #fff; color: var(--text); min-width: 0; transition: all .15s; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.input.full { width: 100%; }
.input.invalid { border-color: var(--red); }
.input.invalid:focus { box-shadow: 0 0 0 3px var(--red-bg); }
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field-label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600;
               margin-bottom: 6px; }
.field-label .when { color: var(--muted); font-weight: 400; font-size: 12px; }
.field-controls { display: flex; gap: 8px; }
.field-controls .input { flex: 1; }

/* ---- Bits & pieces ----------------------------------------------------- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 650;
        padding: 2px 9px; border-radius: 999px; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--green-bg); color: var(--green); }
.pill.off { background: var(--red-bg); color: var(--red); }
.pill.run { background: var(--accent-soft); color: var(--accent); }
.pill.wait { background: var(--amber-bg); color: var(--amber-text); }
.pill.bad { background: var(--red-bg); color: var(--red); }

.chip { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 6px;
        letter-spacing: .4px; }
.chip.LWS { background: #e0eaff; color: #1d4ed8; }
.chip.MX1 { background: #d1fadf; color: #067647; }

.banner { border-radius: 10px; padding: 11px 14px; font-size: 13.5px; margin-bottom: 16px; border: 1px solid; }
.banner.warn { background: var(--amber-bg); border-color: var(--amber-border); color: var(--amber-text); }
.banner.error { background: var(--red-bg); border-color: #f2b8b5; color: var(--red); }
.banner.ok { background: var(--green-bg); border-color: #a9dfc2; color: var(--green); }
.banner:last-child { margin-bottom: 0; }
.banner a { color: inherit; font-weight: 700; text-underline-offset: 2px; }
#alerts:not(:empty) { margin-bottom: 16px; }

.stats { display: flex; gap: 10px; flex-wrap: wrap; align-items: stretch; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
        padding: 8px 16px; box-shadow: var(--shadow); min-width: 86px; }
.stat .n { font-size: 19px; font-weight: 700; line-height: 1.25; }
.stat .l { font-size: 11px; color: var(--muted); font-weight: 650; letter-spacing: .5px; text-transform: uppercase; }

.bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.bar .input { flex: 1; min-width: 240px; }

.state { padding: 52px 20px; text-align: center; color: var(--muted); font-size: 14px; }
.muted { color: var(--muted); font-size: 12.5px; }

.copy-btn { border: none; background: none; cursor: pointer; color: var(--muted); padding: 2px 5px;
            border-radius: 6px; vertical-align: -2px; line-height: 1; transition: all .15s; }
.copy-btn:hover { color: var(--accent); background: var(--accent-soft); }
.copy-btn svg { display: block; }
.rowactions { display: flex; gap: 6px; justify-content: flex-end; }
.job-error { color: var(--red); font-size: 12px; max-width: 520px; margin-top: 4px; }
.field-help { color: var(--muted); font-size: 12px; margin-top: 5px; }
.inline-error { color: var(--red); font-size: 12.5px; margin-top: 5px; font-weight: 550; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
                   overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ---- Dialog ------------------------------------------------------------ */
dialog { border: none; border-radius: 16px; padding: 0; width: 430px; max-width: calc(100vw - 32px);
         box-shadow: 0 24px 60px rgba(16, 19, 34, .3); }
dialog::backdrop { background: rgba(16, 19, 34, .55); }
.modal-dialog { width: 510px; overflow: hidden; }
.modal-dialog.wide { width: 660px; }
.modal-dialog form { margin: 0; }
.dialog-header { padding: 20px 22px 17px; border-bottom: 1px solid var(--border); display: flex;
                 align-items: flex-start; justify-content: space-between; gap: 16px; }
.dialog-header h3 { margin: 0; font-size: 17px; line-height: 1.35; }
.dialog-header p { color: var(--muted); margin: 4px 0 0; font-size: 12.5px; }
.dialog-content { padding: 20px 22px; max-height: min(680px, calc(100vh - 170px)); overflow-y: auto; }
.dialog-content .field:last-of-type { margin-bottom: 0; }
.dialog-footer { min-height: 64px; padding: 14px 22px; border-top: 1px solid var(--border); display: flex;
                 justify-content: flex-end; align-items: center; gap: 8px; background: #fafbfc; }
.icon-btn { appearance: none; border: 0; background: transparent; color: var(--muted); border-radius: 7px;
            cursor: pointer; padding: 0 6px; font: 400 26px/1.2 var(--font); }
.icon-btn:hover { color: var(--text); background: #eef0f3; }
.icon-btn.small { margin-left: auto; font-size: 20px; }
.icon-btn:disabled { opacity: .45; cursor: default; }
.modal-banner { margin: 0 0 16px; }
.modal-safe { color: var(--green); font-size: 12.5px; font-weight: 600; margin-right: auto; }

.drop-zone { border: 1.5px dashed var(--border-strong); border-radius: 12px; padding: 24px 18px;
             display: grid; justify-items: center; text-align: center; color: var(--muted); cursor: pointer;
             background: #fafbfc; transition: border-color .15s, background .15s, color .15s; }
.drop-zone strong { color: var(--text); }
.drop-zone > span { font-size: 12px; margin-top: 4px; }
.drop-zone svg { margin-bottom: 8px; color: var(--accent); }
.drop-zone:hover, .drop-zone:focus-visible, .drop-zone.dragging {
  outline: none; border-color: var(--accent); color: var(--accent); background: var(--accent-soft);
}
.drop-zone.invalid { border-color: var(--red); background: var(--red-bg); }
.drop-link { color: var(--accent); font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.selected-file { border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px; display: flex;
                 align-items: center; gap: 11px; background: #fafbfc; }
.selected-file[hidden] { display: none; }
.selected-file strong, .selected-file small { display: block; }
.selected-file strong { max-width: 440px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selected-file small { color: var(--muted); margin-top: 1px; }
.file-icon { flex: 0 0 auto; padding: 4px 6px; border-radius: 5px; background: var(--accent-soft);
             color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .5px; }

.upload-panel { margin-top: 16px; padding: 13px 14px; border: 1px solid var(--border); border-radius: 10px; background: #fafbfc; }
.progress-label { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; font-size: 12.5px; }
.progress-label strong { color: var(--accent); }
.upload-panel progress { display: block; width: 100%; height: 9px; border: 0; border-radius: 999px;
                         overflow: hidden; background: #e4e7ec; accent-color: var(--accent); }
.upload-panel progress::-webkit-progress-bar { background: #e4e7ec; border-radius: 999px; }
.upload-panel progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; transition: width .15s; }
.upload-panel progress::-moz-progress-bar { background: var(--accent); border-radius: 999px; }

.job-progress { margin-top: 16px; border: 1px solid var(--border); border-radius: 12px; padding: 15px 16px; }
.job-progress-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 13px; }
.job-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px 12px; list-style: none; margin: 0; padding: 0; }
.job-steps li { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--muted); font-size: 11.5px; line-height: 1.3; }
.step-marker { width: 21px; height: 21px; flex: 0 0 21px; display: grid; place-items: center; border-radius: 50%;
               border: 1px solid var(--border-strong); background: #fff; font-size: 10px; font-weight: 750; }
.job-steps li.complete { color: var(--green); }
.job-steps li.complete .step-marker { border-color: var(--green); background: var(--green-bg); }
.job-steps li.current { color: var(--accent); font-weight: 700; }
.job-steps li.current .step-marker { border-color: var(--accent); background: var(--accent); color: #fff;
                                     box-shadow: 0 0 0 3px var(--accent-soft); }
.job-steps li.current.waiting { color: var(--amber-text); }
.job-steps li.current.waiting .step-marker { border-color: var(--amber-text); background: var(--amber-bg); color: var(--amber-text); box-shadow: none; }
.job-steps li.current.failed { color: var(--red); }
.job-steps li.current.failed .step-marker { border-color: var(--red); background: var(--red-bg); color: var(--red); box-shadow: none; }

.input-with-suffix { display: flex; align-items: stretch; }
.input-with-suffix .input { flex: 1; border-radius: 8px 0 0 8px; }
.input-with-suffix > span { display: flex; align-items: center; padding: 0 11px; border: 1px solid var(--border-strong);
                           border-left: 0; border-radius: 0 8px 8px 0; background: #f6f7f9; color: var(--muted); font-size: 13px; }
.availability { min-height: 20px; margin-top: 7px; font-size: 12.5px; font-weight: 600; }
.availability.checking { color: var(--muted); }
.availability.available { color: var(--green); }
.availability.taken { color: var(--red); }

.dialog-body { padding: 24px; }
.dialog-body h3 { margin: 0 0 4px; font-size: 16px; }
.dialog-actions { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.secret { font: 700 16px/1.5 ui-monospace, "SF Mono", Menlo, monospace; background: var(--bg);
          border: 1px dashed var(--border-strong); border-radius: 10px; padding: 13px 15px;
          margin: 14px 0; word-break: break-all; user-select: all; text-align: center; }

/* ---- Login ------------------------------------------------------------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
             background: radial-gradient(900px 500px at 15% 0%, #e9e8fd 0%, transparent 55%),
                         radial-gradient(800px 500px at 100% 100%, #e5f0ff 0%, transparent 50%),
                         var(--bg); }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
             box-shadow: 0 8px 30px rgba(16, 24, 40, .08); padding: 34px 32px; width: 380px;
             max-width: 100%; }
.auth-brand { display: flex; align-items: center; gap: 11px; font-weight: 700; font-size: 16px;
              margin-bottom: 6px; }
.auth-brand .mark { width: 32px; height: 32px; border-radius: 9px;
                    background: linear-gradient(135deg, #6366f1, #8b5cf6); display: grid; place-items: center; }
.auth-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 22px; }
.auth-card label { display: block; font-size: 13px; font-weight: 600; margin: 0 0 6px; }
.auth-card .input { width: 100%; margin-bottom: 14px; }
.auth-card .btn { width: 100%; padding: 9px; font-size: 14px; margin-top: 4px; }
#error { color: var(--red); font-size: 13px; min-height: 20px; margin-bottom: 2px; }

/* ---- Responsive -------------------------------------------------------- */
@media (max-width: 880px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center;
             padding: 10px 14px; gap: 6px; }
  .brand { padding: 0 10px 0 0; }
  .nav { flex-direction: row; }
  .nav a { padding: 7px 10px; }
  .sidebar-footer { margin: 0 0 0 auto; border-top: none; padding: 0; flex-direction: row; align-items: center; }
  .user-email { display: none; }
  .main { padding: 18px 16px 40px; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .job-steps { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .dialog-header, .dialog-content, .dialog-footer { padding-left: 16px; padding-right: 16px; }
  .dialog-footer { flex-wrap: wrap; }
  .modal-safe { width: 100%; margin: 0 0 2px; }
  .job-steps { grid-template-columns: 1fr; }
  .input-with-suffix { flex-direction: column; }
  .input-with-suffix .input { border-radius: 8px 8px 0 0; }
  .input-with-suffix > span { border-left: 1px solid var(--border-strong); border-top: 0; border-radius: 0 0 8px 8px;
                             padding-top: 7px; padding-bottom: 7px; }
}
