:root {
  --ink: #172129;
  --muted: #64727d;
  --line: #dbe2e7;
  --surface: #ffffff;
  --canvas: #f3f6f7;
  --nav: #1f2930;
  --teal: #087f73;
  --teal-soft: #e4f4f1;
  --green: #15805d;
  --green-soft: #e7f5ee;
  --red: #c43b46;
  --red-soft: #fcebed;
  --amber: #a8640a;
  --amber-soft: #fff2dc;
  --blue: #326ca8;
  --shadow: 0 8px 26px rgba(24, 39, 48, 0.07);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(rgba(255,255,255,0.72), rgba(255,255,255,0.72)),
    repeating-linear-gradient(90deg, transparent 0 47px, rgba(25,62,77,0.035) 48px),
    var(--canvas);
  font-family: "Manrope", sans-serif;
  letter-spacing: 0;
}

button, input, select { font: inherit; letter-spacing: 0; }

.app-header {
  min-height: 76px;
  padding: 14px clamp(18px, 3vw, 42px);
  color: #f7fbfc;
  background: var(--nav);
  border-bottom: 3px solid var(--teal);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand-block, .header-actions, .primary-button, .health-banner,
.refresh-control, .search-field, .filter-field { display: flex; align-items: center; }

.brand-block { gap: 13px; min-width: 0; }

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: 0 0 40px;
  color: white;
  background: var(--teal);
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 6px;
  font-family: "Source Code Pro", monospace;
  font-weight: 700;
}

h1, h2, p { margin: 0; }
h1 { font-size: 18px; line-height: 1.25; }
.brand-block p { margin-top: 3px; color: #acbbc4; font-size: 12px; }

.header-actions { gap: 10px; }
.workspace-switcher { display: flex; align-items: center; gap: 7px; }
.workspace-switcher label { color: #b8c5cc; font-size: 10px; font-weight: 700; text-transform: uppercase; }
.workspace-switcher select { max-width: 190px; height: 34px; padding: 0 9px; font-size: 11px; }
.refresh-control { gap: 8px; color: #b8c5cc; font-size: 12px; }
.user-nav { display: flex; align-items: center; gap: 9px; color: #b8c5cc; font-size: 11px; }
.user-nav form { margin: 0; }
.admin-nav { display: flex; align-items: center; gap: 7px; }
.nav-button { min-height: 32px; padding: 0 10px; display: inline-flex; align-items: center; gap: 6px; color: #eef5f6; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.18); border-radius: 5px; text-decoration: none; font-size: 11px; font-weight: 700; }
.nav-button:hover { color: white; background: rgba(8,127,115,0.55); border-color: rgba(255,255,255,0.35); }
.nav-button svg { width: 14px; height: 14px; }
.header-link { padding: 0; color: #dce7ea; background: none; border: 0; cursor: pointer; text-decoration: none; font-size: 11px; }
.header-link:hover { color: white; }

select, input {
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 5px;
  outline: none;
}

select:focus, input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(8,127,115,0.12); }
.refresh-control select { min-width: 90px; padding: 8px 28px 8px 9px; }

.primary-button {
  height: 36px;
  gap: 8px;
  padding: 0 14px;
  color: white;
  background: var(--teal);
  border: 0;
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.primary-button:hover { background: #066d63; }
.primary-button:disabled { opacity: 0.66; cursor: wait; }
.primary-button svg { width: 16px; height: 16px; }
.primary-button.loading svg { animation: spin 0.8s linear infinite; }

main { width: min(1500px, calc(100% - 36px)); margin: 22px auto 48px; }

.health-banner {
  min-height: 58px;
  gap: 12px;
  padding: 11px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--teal);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.health-banner.failed { background: var(--red-soft); border-left-color: var(--red); }
.health-banner.running { background: var(--amber-soft); border-left-color: var(--amber); }
.health-banner.healthy { background: var(--green-soft); border-left-color: var(--green); }

.health-indicator { width: 10px; height: 10px; border-radius: 50%; background: var(--teal); flex: 0 0 10px; }
.failed .health-indicator { background: var(--red); }
.running .health-indicator { background: var(--amber); }
.healthy .health-indicator { background: var(--green); }
.health-banner strong { display: block; font-size: 14px; }
.health-banner span { color: var(--muted); font-size: 12px; }
.health-banner time { margin-left: auto; color: var(--muted); font-size: 11px; white-space: nowrap; }
.freshness-meta { margin-left: auto; display: grid; gap: 3px; text-align: right; }
.freshness-meta time { margin-left: 0; }

.range-bar { min-height: 66px; margin-top: 12px; padding: 12px 15px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.range-bar strong { font-size: 13px; }
.date-range-controls { display: flex; align-items: end; gap: 9px; }
.date-range-controls label { display: grid; gap: 4px; color: var(--muted); font-size: 9px; font-weight: 700; text-transform: uppercase; }
.date-range-controls input { height: 34px; padding: 0 8px; font-size: 11px; text-transform: none; }
.range-button { height: 34px; }
.history-range-bar { padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 18px; background: #f7faf9; border-bottom: 1px solid var(--line); }
.history-range-bar strong { font-size: 12px; }

.kpi-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(5, minmax(145px, 1fr));
  gap: 10px;
}

.kpi {
  min-height: 112px;
  padding: 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid var(--blue);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.kpi span, .kpi small { display: block; color: var(--muted); font-size: 11px; }
.kpi strong { display: block; margin: 7px 0 4px; font-size: 30px; line-height: 1; }
.kpi-failed { border-top-color: var(--red); }
.kpi-running { border-top-color: var(--amber); }
.kpi-success { border-top-color: var(--green); }
.kpi-warning { border-top-color: #d1771c; }

.chart-grid { margin-top: 14px; display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 14px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); }
.chart-panel { min-width: 0; padding: 17px; }
.panel-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.panel-heading h2 { font-size: 15px; }
.panel-heading > span { color: var(--muted); font-size: 11px; text-align: right; }
.eyebrow { margin-bottom: 3px; color: var(--teal); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.chart-frame { position: relative; height: 270px; margin-top: 18px; }

.workspace { margin-top: 14px; overflow: hidden; }
.tabs { min-height: 48px; padding: 0 14px; border-bottom: 1px solid var(--line); display: flex; gap: 22px; }
.tab { position: relative; padding: 0 2px; color: var(--muted); background: transparent; border: 0; cursor: pointer; font-size: 12px; font-weight: 700; }
.tab.active { color: var(--ink); }
.tab.active::after { content: ""; position: absolute; right: 0; bottom: -1px; left: 0; height: 3px; background: var(--teal); }

.table-toolbar { padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 14px; background: #fafcfc; border-bottom: 1px solid var(--line); }
.search-field { position: relative; width: min(440px, 100%); }
.search-field svg { position: absolute; left: 10px; width: 15px; color: var(--muted); }
.search-field input { width: 100%; height: 36px; padding: 0 12px 0 34px; font-size: 12px; }
.filter-field { gap: 8px; color: var(--muted); font-size: 11px; }
.filter-field select { height: 36px; min-width: 110px; padding: 0 9px; font-size: 12px; }
.pagination-bar { min-height: 50px; padding: 9px 14px; display: flex; align-items: center; justify-content: space-between; gap: 14px; color: var(--muted); background: #fafcfc; border-top: 1px solid var(--line); font-size: 10px; }
.pagination-actions { display: flex; align-items: center; gap: 8px; }
.pagination-actions label { display: flex; align-items: center; gap: 6px; font-weight: 700; text-transform: uppercase; }
.pagination-actions select { height: 31px; padding: 0 7px; font-size: 10px; }
.pagination-actions .secondary-button { min-width: 68px; }

.table-wrap { max-height: 620px; overflow: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px; }
th { position: sticky; top: 0; z-index: 2; padding: 10px 12px; color: #59666e; background: #f0f4f5; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; font-size: 10px; text-transform: uppercase; }
td { max-width: 340px; padding: 11px 12px; border-bottom: 1px solid #e8edef; vertical-align: middle; }
tbody tr:hover { background: #f7faf9; }
.workflow-name { display: block; font-weight: 700; overflow-wrap: anywhere; }
.workflow-link { display: block; padding: 0; color: var(--ink); background: none; border: 0; cursor: pointer; font-weight: 700; text-align: left; overflow-wrap: anywhere; }
.workflow-link:hover { color: var(--teal); text-decoration: underline; }
.workflow-id { display: block; margin-top: 3px; color: var(--muted); font-family: "Source Code Pro", monospace; font-size: 9px; overflow-wrap: anywhere; }
.status-badge { display: inline-flex; min-width: 72px; justify-content: center; padding: 4px 8px; border-radius: 999px; font-size: 9px; font-weight: 700; }
.status-SUCCESS { color: var(--green); background: var(--green-soft); }
.status-FAILED { color: var(--red); background: var(--red-soft); }
.status-RUNNING { color: var(--amber); background: var(--amber-soft); }
.status-UNKNOWN { color: var(--muted); background: #edf1f3; }
.error-text { color: var(--red); overflow-wrap: anywhere; }
.mono { font-family: "Source Code Pro", monospace; font-size: 10px; }
.empty-row td { padding: 34px; color: var(--muted); text-align: center; }

.error-toast { position: fixed; right: 18px; bottom: 18px; max-width: 430px; padding: 13px 15px; color: #751d25; background: var(--red-soft); border: 1px solid #efbdc2; border-radius: 6px; box-shadow: var(--shadow); font-size: 12px; }

.auth-page { min-height: 100vh; background: var(--nav); }
.login-shell { min-height: 100vh; width: 100%; margin: 0; padding: 24px; display: grid; place-items: center; }
.login-panel { width: min(420px, 100%); padding: 34px; background: var(--surface); border-top: 4px solid var(--teal); border-radius: 7px; box-shadow: 0 24px 70px rgba(0,0,0,0.28); }
.login-panel .brand-mark { margin-bottom: 26px; }
.login-panel h1 { margin-bottom: 9px; color: var(--ink); font-size: 25px; }
.login-copy { margin-bottom: 24px; color: var(--muted); line-height: 1.6; }
.login-panel small { display: block; margin-top: 18px; color: var(--muted); font-size: 10px; }
.login-error { margin-bottom: 18px; padding: 10px 12px; color: #751d25; background: var(--red-soft); border-left: 3px solid var(--red); font-size: 12px; }
.microsoft-button { min-height: 44px; padding: 0 15px; display: flex; align-items: center; justify-content: center; gap: 11px; color: white; background: #315ea8; border-radius: 5px; text-decoration: none; font-size: 13px; font-weight: 700; }
.microsoft-button:hover { background: #254d91; }
.microsoft-grid { width: 17px; height: 17px; display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.microsoft-grid i:nth-child(1) { background: #f35325; }
.microsoft-grid i:nth-child(2) { background: #81bc06; }
.microsoft-grid i:nth-child(3) { background: #05a6f0; }
.microsoft-grid i:nth-child(4) { background: #ffba08; }

.admin-main { width: min(1200px, calc(100% - 36px)); }
.admin-create { padding: 18px; }
.admin-form { margin-top: 16px; display: grid; grid-template-columns: 1.3fr 1fr 130px 1fr 130px auto; align-items: end; gap: 12px; }
.admin-form label { display: grid; gap: 5px; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.admin-form input, .admin-form select { height: 38px; padding: 0 10px; font-size: 12px; text-transform: none; }
.workflow-form { margin-top: 16px; display: grid; grid-template-columns: 1.1fr 1.3fr 0.7fr auto; align-items: end; gap: 12px; }
.workflow-form label { display: grid; gap: 5px; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.workflow-form input { height: 38px; padding: 0 10px; font-size: 12px; text-transform: none; }
.workspace-form { margin-top: 16px; display: grid; grid-template-columns: 1fr 0.8fr 1fr 1.2fr auto; align-items: end; gap: 12px; }
.workspace-form label { display: grid; gap: 5px; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.workspace-form input { height: 38px; padding: 0 10px; font-size: 12px; text-transform: none; }
.workflow-actions { display: flex; align-items: center; gap: 7px; }
.workflow-actions form { margin: 0; }
.workflow-actions details { position: relative; }
.workflow-actions summary { min-height: 31px; padding: 7px 10px; list-style: none; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 4px; cursor: pointer; font-size: 10px; }
.inline-edit-form { position: absolute; z-index: 5; top: 36px; right: 0; width: 300px; padding: 10px; display: grid; gap: 7px; background: white; border: 1px solid var(--line); border-radius: 5px; box-shadow: var(--shadow); }
.inline-edit-form input { height: 34px; padding: 0 8px; font-size: 11px; }
.inline-edit-actions { display: flex; justify-content: flex-end; gap: 7px; }
.inline-edit-actions .primary-button { height: 31px; font-size: 10px; }
.admin-list { margin-top: 14px; overflow: hidden; }
.admin-heading { padding: 17px; }
.admin-identity { color: #b8c5cc; font-size: 11px; }
.secondary-button { min-height: 31px; padding: 0 10px; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 4px; cursor: pointer; font-size: 10px; }
.secondary-button:disabled { opacity: 0.45; cursor: not-allowed; }
.flash { margin-bottom: 10px; padding: 11px 13px; border-radius: 5px; font-size: 12px; }
.flash-success { color: var(--green); background: var(--green-soft); }
.flash-error { color: var(--red); background: var(--red-soft); }
.membership-cell { min-width: 430px; }
.membership-list { display: grid; gap: 6px; }
.membership-item { display: grid; grid-template-columns: minmax(100px, 1fr) 82px 72px auto auto; align-items: center; gap: 6px; }
.membership-item select, .membership-add select { height: 31px; padding: 0 7px; font-size: 10px; }
.membership-item strong { overflow-wrap: anywhere; font-size: 10px; }
.default-mark { color: var(--teal); font-size: 9px; font-weight: 700; text-transform: uppercase; }
.default-choice { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 9px; white-space: nowrap; }
.default-choice input { width: 13px; height: 13px; }
.membership-add { margin-top: 8px; }
.membership-add summary { color: var(--teal); cursor: pointer; font-size: 10px; font-weight: 700; }
.membership-add form { margin-top: 6px; display: flex; align-items: center; gap: 6px; }
.membership-add .primary-button { height: 31px; font-size: 10px; }

.task-dialog { width: min(1180px, calc(100% - 30px)); max-height: min(760px, calc(100vh - 40px)); padding: 0; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 7px; box-shadow: 0 28px 90px rgba(0,0,0,0.3); }
.task-dialog::backdrop { background: rgba(17,31,39,0.72); }
.dialog-heading { padding: 17px; display: flex; align-items: start; justify-content: space-between; border-bottom: 1px solid var(--line); }
.dialog-heading h2 { margin-bottom: 4px; font-size: 16px; }
.icon-button { width: 34px; height: 34px; display: grid; place-items: center; color: var(--muted); background: white; border: 1px solid var(--line); border-radius: 4px; cursor: pointer; font-size: 22px; }
.task-table-wrap { max-height: 600px; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 980px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .app-header { align-items: flex-start; flex-direction: column; }
  .header-actions { width: 100%; align-items: stretch; flex-direction: column; }
  .user-nav { width: 100%; align-items: flex-start; justify-content: space-between; }
  .user-nav form { margin-left: auto; }
  .refresh-control { width: 100%; justify-content: space-between; }
  .refresh-control select { flex: 1; }
  .header-actions > .primary-button { width: 100%; justify-content: center; }
  main { width: min(100% - 20px, 1500px); margin-top: 12px; }
  .health-banner { align-items: flex-start; }
  .freshness-meta { display: none; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi { min-height: 102px; }
  .table-toolbar { align-items: stretch; flex-direction: column; }
  .search-field { width: 100%; }
  .filter-field { justify-content: space-between; }
  .tabs { gap: 14px; overflow-x: auto; }
  .tab { min-height: 46px; white-space: nowrap; }
  .user-nav > span { display: none; }
  .admin-form, .workflow-form, .workspace-form { grid-template-columns: 1fr; }
  .range-bar { align-items: stretch; flex-direction: column; }
  .history-range-bar { align-items: stretch; flex-direction: column; }
  .date-range-controls { display: grid; grid-template-columns: 1fr 1fr; }
  .range-button { grid-column: 1 / -1; }
  .admin-nav { flex: 1; flex-wrap: wrap; }
  .workspace-switcher { width: 100%; }
  .workspace-switcher select { max-width: none; flex: 1; }
  .membership-item { grid-template-columns: 1fr 82px; }
  .membership-add form { align-items: stretch; flex-direction: column; }
  .pagination-bar { align-items: stretch; flex-direction: column; }
  .pagination-actions { justify-content: space-between; flex-wrap: wrap; }
}