* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  background: #071522;
  color: #ecf6fa;
  font-family: Arial, Helvetica, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 3px solid #48aef7; outline-offset: 3px; }

.eyebrow { color: #72bef7; font-size: 11px; font-weight: 700; letter-spacing: 2.1px; }
.primary-button, .secondary-button, .header-button, .header-link {
  border-radius: 10px;
  display: inline-block;
  font-size: 14px;
  font-weight: 700;
  line-height: 20px;
  padding: 10px 17px;
  text-align: center;
  white-space: nowrap;
}
.primary-button { background: #168de2; border: 1px solid #168de2; color: #fff; }
.primary-button:hover, .primary-button:focus { background: #36a6f3; }
.secondary-button, .header-button, .header-link { background: #153248; border: 1px solid #2a4a5e; color: #e1f2f6; }
.secondary-button:hover, .header-button:hover, .header-link:hover { background: #204358; }
.header-button.subtle { background: transparent; }
.danger-button { color: #ffbbb8; border-color: #7d4a51; }

/* Panel dashboard: at most nine visible cards and no page scroll. */
.dashboard-body { height: 100vh; overflow: hidden; background: #11151c; color: #eef1f6; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.panel-header {
  height: 96px;
  padding: 0 28px;
  background: #191e27;
  border-bottom: 1px solid #333b48;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand-row, .header-right { display: flex; align-items: center; }
.brand-row { min-width: 0; }
.brand-mark, .login-mark, .config-mark { display: block; object-fit: contain; flex: none; }
.brand-mark { height: 48px; width: 48px; margin-right: 16px; }
.panel-header h1 { margin: 4px 0 0; font-size: 25px; line-height: 1.1; }
.brand-row > div { min-width: 0; }
.header-collection-times { margin-top: 5px; color: #aeb8c8; font-size: 11px; line-height: 1.3; }
.header-collection-times > span { display: block; }
.header-right { gap: 10px; }
.header-right > * + * { margin-left: 0; }
.dashboard-body .header-button { background: #282f3b; border-color: #434d5d; color: #e5eaf2; }
.dashboard-body .header-button:hover { background: #353e4c; }
.dashboard-body .header-button.subtle { background: transparent; }
.dashboard-body .header-button.subtle:hover { background: #282f3b; }
.clock-block { display: flex; flex-direction: column; align-items: flex-end; margin-right: 13px; white-space: nowrap; }
.current-date { color: #aeb8c8; font-size: 12px; line-height: 1.1; }
.clock { color: #f5f7fa; font-size: 28px; font-weight: 700; letter-spacing: 1px; line-height: 1.15; }
.panel-main { height: calc(100vh - 96px); padding: 0 28px; display: flex; flex-direction: column; }
.panel-status-bar { height: 48px; flex: none; display: flex; align-items: center; justify-content: space-between; color: #b1bccb; font-size: 14px; }
.status-copy { display: flex; align-items: center; min-width: 0; }
.status-actions { display: flex; align-items: center; flex: none; gap: 18px; margin-left: auto; }
.activity-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 9px; background: #24c959; flex: none; }
.activity-dot.warn { background: #ffa529; }
.activity-dot.error { background: #f17d80; }
.page-actions { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.page-actions span { margin-right: 4px; }
.page-actions button { border: 1px solid #434d5d; background: #282f3b; color: #e5eaf2; border-radius: 7px; padding: 5px 13px; }
.page-actions button:disabled { opacity: .4; cursor: default; }
.empty-state { height: calc(100% - 48px); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.empty-icon { border: 2px dashed #505e73; color: #9ec5f7; border-radius: 50%; width: 68px; height: 68px; line-height: 59px; font-size: 38px; margin-bottom: 18px; }
.empty-state h2 { font-size: 28px; margin: 0 0 10px; }
.empty-state p { color: #b1bccb; font-size: 16px; max-width: 450px; margin: 0 0 23px; }
/* Optional light theme for the dashboard; dark remains the default. */
html[data-theme="light"] .dashboard-body { background: #e9eff4; color: #172b3a; }
html[data-theme="light"] .panel-header { background: #f7fafc; border-bottom-color: #ccd9e2; }
html[data-theme="light"] .panel-header h1,
html[data-theme="light"] .clock { color: #172b3a; }
html[data-theme="light"] .current-date,
html[data-theme="light"] .header-collection-times,
html[data-theme="light"] .panel-status-bar { color: #4f6878; }
html[data-theme="light"] .header-button { background: #fff; border-color: #bacbd6; color: #213b4c; }
html[data-theme="light"] .header-button:hover { background: #eaf2f7; }
html[data-theme="light"] .header-button.subtle { background: transparent; }
html[data-theme="light"] .header-button.subtle:hover { background: #eaf2f7; }
html[data-theme="light"] .empty-state h2 { color: #172b3a; }
html[data-theme="light"] .empty-state p { color: #4f6878; }
html[data-theme="light"] .page-actions button { background: #f7fafc; border-color: #bdcdd7; color: #294354; }
html[data-theme="light"] .empty-icon { border-color: #7eabbf; color: #1682c3; }

/* Unified panel and administrative entry. */
.login-body { min-height: 100vh; background: #f6f8fc; color: #0b2345; }
.access-layout { display: grid; grid-template-columns: 55% 45%; min-height: 100vh; }
.access-illustration { position: relative; overflow: hidden; background: linear-gradient(145deg, #143c69, #071e3b); }
.access-illustration img { position: absolute; width: min(85vw, 920px); max-width: none; left: 50%; top: 55%; transform: translate(-50%, -50%); opacity: .12; filter: grayscale(1) brightness(2); }
.access-panel { display: flex; align-items: center; justify-content: center; padding: 42px max(36px, 6vw); }
.access-content { width: min(100%, 464px); text-align: center; }
.login-mark { height: 96px; width: 96px; margin: 0 auto 24px; }
.access-content h1 { margin: 0 0 12px; color: #0b2345; font-size: clamp(36px, 3vw, 46px); line-height: 1.06; letter-spacing: -.03em; }
.login-copy { max-width: 430px; margin: 0 auto 32px; color: #526888; font-size: 19px; line-height: 1.4; }
.login-form { display: flex; flex-direction: column; text-align: left; }
.login-form label, .form-field label { font-weight: 700; font-size: 13px; margin-bottom: 8px; }
.login-form label { color: #0b2345; font-size: 17px; text-align: center; }
.access-token-field { position: relative; }
.login-form input, .form-field input, .form-field select { background: #091d2c; border: 1px solid #3a5a67; border-radius: 9px; color: #f5fbff; outline: none; padding: 12px 13px; width: 100%; }
.login-form input { height: 58px; padding: 14px 55px 14px 18px; background: #fff; border-color: #cad5e6; color: #0b2345; font-size: 17px; letter-spacing: .02em; }
.login-form input::-ms-reveal, .login-form input::-ms-clear { display: none; }
.login-form input::placeholder { color: #617595; opacity: 1; }
.token-visibility-button { position: absolute; right: 8px; top: 50%; display: grid; place-items: center; width: 44px; height: 44px; transform: translateY(-50%); border: 0; background: transparent; color: #163d68; }
.token-visibility-button svg { width: 23px; height: 23px; }
.form-field input[type="file"] { padding: 8px; font-size: 12px; }
.login-form input:focus, .form-field input:focus, .form-field select:focus { border-color: #57acf0; box-shadow: 0 0 0 2px rgba(45,151,232,.16); }
.login-form .access-submit { position: relative; width: 100%; min-height: 58px; margin-top: 20px; background: #0865d7; border-color: #0865d7; border-radius: 8px; font-size: 17px; font-weight: 600; }
.access-submit span, .access-entra-button > span:last-child { position: absolute; right: 19px; top: 50%; transform: translateY(-54%); font-size: 30px; font-weight: 400; line-height: 1; }
.access-divider { display: flex; align-items: center; gap: 20px; margin: 22px 0; color: #526888; font-size: 16px; font-weight: 700; }
.access-divider::before, .access-divider::after { content: ""; flex: 1; height: 1px; background: #d3deeb; }
.access-entra-button { position: relative; display: flex; align-items: center; justify-content: center; gap: 14px; min-height: 58px; padding: 10px 38px; border: 1px solid #cad5e6; border-radius: 8px; background: #fff; color: #233f65; font-size: 16px; font-weight: 600; text-align: center; }
.access-entra-button:hover { background: #edf4fc; }
.microsoft-mark { display: grid; grid-template-columns: repeat(2, 12px); grid-template-rows: repeat(2, 12px); gap: 2px; flex: none; }
.microsoft-mark i:nth-child(1) { background: #f25022; }
.microsoft-mark i:nth-child(2) { background: #7fba00; }
.microsoft-mark i:nth-child(3) { background: #00a4ef; }
.microsoft-mark i:nth-child(4) { background: #ffb900; }
.form-message { color: #ffb6b1; min-height: 20px; font-size: 13px; margin: 12px 0 0; }
.form-message:empty { display: none; }
.login-body .form-message { color: #b82032; }
.login-body .form-message.is-pending { color: #365f90; }
.login-body .form-message.is-error { color: #b82032; }
.page-transition { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; background: #11151c; color: #eef1f6; font-size: 18px; font-weight: 700; }
html[data-theme="light"] .page-transition { background: #e9eff4; color: #172b3a; }

/* Configuration follows the same saved theme as the dashboard. */
.config-body {
  --config-bg: #11151c;
  --config-header: #191e27;
  --config-surface: #222b37;
  --config-soft: #1a222d;
  --config-input: #171f2a;
  --config-border: #3b4858;
  --config-text: #eef1f6;
  --config-muted: #aeb8c8;
  --config-accent: #65aff8;
  min-height: 100vh;
  background: var(--config-bg);
  color: var(--config-text);
  color-scheme: dark;
}
html[data-theme="light"] .config-body {
  --config-bg: #e9eff4;
  --config-header: #f7fafc;
  --config-surface: #fff;
  --config-soft: #f2f6fa;
  --config-input: #fff;
  --config-border: #ccd9e2;
  --config-text: #172b3a;
  --config-muted: #4f6878;
  --config-accent: #0869bd;
  color-scheme: light;
}
.config-header { background: var(--config-header); border-bottom: 1px solid var(--config-border); }
.config-header-inner { max-width: 1180px; min-height: 88px; margin: 0 auto; padding: 16px 22px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.config-brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.config-mark { height: 46px; width: 46px; }
.config-header .eyebrow { color: var(--config-accent); font-size: 10px; letter-spacing: 1.6px; }
.config-header h1 { margin: 3px 0 0; color: var(--config-text); font-size: 25px; line-height: 1.1; }
.config-header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.config-body .back-link, .config-body .header-button, .config-body .secondary-button { color: var(--config-text); background: var(--config-surface); border: 1px solid var(--config-border); }
.config-body .back-link { display: inline-flex; align-items: center; min-height: 40px; border-radius: 9px; padding: 8px 14px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.config-body .back-link:hover, .config-body .header-button:hover, .config-body .secondary-button:hover { background: var(--config-soft); }
.config-body .header-button.subtle { background: transparent; }
.config-body .header-button.subtle:hover { background: var(--config-soft); }
.config-body .danger-button { color: #f198a0; border-color: #8b5963; }
html[data-theme="light"] .config-body .danger-button { color: #a92d3e; border-color: #e3b9bf; }
.config-main { width: 100%; max-width: 1180px; margin: 0 auto; padding: 28px 22px 56px; }
.config-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); align-items: start; gap: 24px; }
.config-content { min-width: 0; }
.config-page-navigation { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--config-border); border-radius: 14px; background: var(--config-header); }
.config-nav-label { padding: 6px 10px 8px; color: var(--config-muted); font-size: 10px; font-weight: 700; letter-spacing: 1.6px; }
.config-page-navigation a { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 11px 12px; border: 1px solid transparent; border-radius: 9px; color: var(--config-text); font-size: 14px; font-weight: 700; }
.config-page-navigation a:hover { background: var(--config-soft); }
.config-page-navigation a[aria-current="page"] { border-color: var(--config-border); background: var(--config-surface); box-shadow: inset 3px 0 #168de2; }
.config-nav-number { color: var(--config-accent); font-size: 12px; font-variant-numeric: tabular-nums; }
.config-page-navigation a small { display: block; margin-top: 3px; color: var(--config-muted); font-size: 11px; font-weight: 400; line-height: 1.25; }
.config-page-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--config-muted); font-size: 13px; }
.config-page-footer button:disabled { opacity: .45; cursor: default; }
.config-panel { padding: 26px 28px; margin-bottom: 18px; border: 1px solid var(--config-border); border-radius: 15px; background: var(--config-surface); box-shadow: 0 12px 28px rgba(0,0,0,.07); }
.section-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding-bottom: 20px; margin-bottom: 24px; border-bottom: 1px solid var(--config-border); }
.section-heading h2 { margin: 0 0 7px; color: var(--config-text); font-size: 22px; }
.section-heading p { margin: 0; max-width: 650px; color: var(--config-muted); font-size: 13px; line-height: 1.5; }
.section-heading p + p { margin-top: 5px; }
.config-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 17px; }
.form-field { display: flex; flex-direction: column; flex: 1 1 250px; min-width: 180px; }
.config-body .form-field label { color: var(--config-text); }
.config-body .form-field input:not([type="checkbox"]), .config-body .form-field select { min-height: 44px; background: var(--config-input); border-color: var(--config-border); color: var(--config-text); }
.config-body .form-field input::placeholder { color: var(--config-muted); opacity: .8; }
.form-field small { color: var(--config-muted); margin-top: 7px; font-size: 11px; line-height: 1.4; }
.unit-type-field { flex: 0 1 190px; }
.logo-field { flex: 1 1 270px; }
.unit-logo-preview-wrap { display: flex; align-items: center; gap: 10px; margin-top: 10px; color: var(--config-muted); font-size: 11px; }
.unit-logo-preview { width: 52px; height: 52px; padding: 4px; object-fit: contain; background: #fff; border: 1px solid var(--config-border); border-radius: 8px; }
.logo-remove-choice { display: flex; align-items: center; gap: 7px; margin-top: 9px; color: #ffbbb8 !important; font-size: 11px !important; font-weight: 400 !important; cursor: pointer; }
html[data-theme="light"] .logo-remove-choice { color: #a92d3e !important; }
.config-body .logo-remove-choice input { width: 15px; height: 15px; flex: none; padding: 0; accent-color: #db5960; }
.narrow-field { flex: 0 1 190px; }
.form-actions { display: flex; gap: 9px; align-items: center; flex: 0 0 auto; }
.global-settings-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 18px 20px; }
.global-settings-form .form-field { min-width: 0; }
.global-settings-form .form-field label { display: block; line-height: 1.2; }
.global-settings-form .form-field input { min-height: 44px; }
.global-settings-form .form-actions { grid-column: 1 / -1; padding-top: 16px; border-top: 1px solid var(--config-border); }
.global-settings-form .form-actions button { min-height: 44px; }
.unit-form { border-bottom: 1px solid var(--config-border); padding-bottom: 22px; margin-bottom: 7px; }
#unit-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(150px, .65fr); align-items: start; gap: 18px 20px; }
#unit-form .form-field { min-width: 0; }
#unit-form .logo-field { grid-column: 1 / -1; padding: 16px; border: 1px dashed var(--config-border); border-radius: 10px; background: var(--config-soft); }
#unit-form .form-actions { grid-column: 1 / -1; }
#unit-form .form-field input:not([type="checkbox"]), #unit-form .form-field select { height: 44px; }
#unit-form input[type="file"] { padding: 9px; height: auto !important; }
.unit-list { width: 100%; }
.unit-list-empty { color: var(--config-muted); font-size: 13px; padding: 19px 0 4px; }
.unit-list-row { display: flex; justify-content: space-between; align-items: center; gap: 15px; padding: 14px 16px; margin-top: 10px; border: 1px solid var(--config-border); border-radius: 10px; background: var(--config-soft); }
.unit-list-detail { display: flex; align-items: center; gap: 12px; min-width: 0; }
.unit-list-logo { width: 42px; height: 42px; flex: none; object-fit: contain; padding: 3px; background: #fff; border-radius: 7px; }
.unit-list-copy { min-width: 0; }
.unit-list-name { font-weight: 700; font-size: 14px; margin-bottom: 3px; }
.unit-list-type { color: var(--config-accent); font-size: 10px; font-weight: 700; margin-bottom: 4px; text-transform: uppercase; letter-spacing: .7px; }
.unit-list-url { color: var(--config-muted); font-size: 12px; overflow-wrap: anywhere; }
.unit-list-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.unit-list-actions button { padding: 6px 10px; font-size: 12px; }
.count-pill { color: var(--config-accent); border: 1px solid var(--config-border); background: var(--config-soft); border-radius: 99px; padding: 6px 12px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.collector-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.auto-start-form { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 0 0 18px; padding: 16px; background: var(--config-soft); border: 1px solid var(--config-border); border-radius: 10px; }
.auto-start-choice { display: flex; align-items: center; gap: 11px; cursor: pointer; }
.auto-start-choice input { width: 19px; height: 19px; accent-color: #168de2; flex: none; }
.auto-start-choice span { display: flex; flex-direction: column; gap: 5px; }
.auto-start-choice strong { color: var(--config-text); font-size: 13px; }
.auto-start-choice small { color: var(--config-muted); font-size: 11px; }
.notice { padding: 13px 16px; border-radius: 10px; background: #123e2b; color: #8ee9a5; border: 1px solid #2d7044; margin: 0 0 20px; font-size: 13px; }
.notice.error { color: #ffd1c9; background: #4a282c; border-color: #8b4a51; }
.token-panel { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 16px; margin: 15px 0; border-radius: 10px; background: var(--config-soft); border: 1px solid var(--config-border); }
.token-panel label { width: 100%; color: var(--config-text); font-size: 13px; font-weight: 700; }
.token-panel input { min-width: 240px; flex: 1; padding: 11px 12px; background: var(--config-input); border: 1px solid var(--config-border); border-radius: 8px; color: var(--config-text); font: 14px monospace; letter-spacing: 1px; }
html[data-theme="light"] .notice { background: #e4f4ea; color: #176b3b; border-color: #b7dfc6; }
html[data-theme="light"] .notice.error { background: #fff0f0; color: #a92d3e; border-color: #efc7cc; }

/* Compact dashboard chrome leaves room for the nine-card grid. */
@media (max-width: 1600px) {
  .panel-header { height: 74px; padding: 0 18px; }
  .brand-mark { width: 38px; height: 38px; margin-right: 11px; }
  .panel-header h1 { font-size: 20px; }
  .header-collection-times { margin-top: 3px; font-size: 10px; }
  .panel-header .eyebrow { font-size: 9px; }
  .clock-block { margin-right: 4px; }
  .current-date { font-size: 10px; }
  .clock { font-size: 23px; }
  .header-button, .header-link { padding: 7px 10px; font-size: 12px; }
  .panel-main { height: calc(100vh - 74px); padding: 0 16px; }
  .panel-status-bar { height: 36px; font-size: 12px; }
  .status-actions { gap: 10px; }
  .page-actions button { padding: 2px 8px; }
}

@media (max-width: 920px) {
  .access-layout { grid-template-columns: 38% 62%; }
  .access-panel { padding: 36px; }
  .access-illustration img { width: 650px; }
  .config-layout { display: block; }
  .config-page-navigation { position: static; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 20px; }
  .config-nav-label { grid-column: 1 / -1; }
  .config-page-navigation a { padding: 10px; }
  .config-page-navigation a small { display: none; }
}

@media (max-width: 760px) {
  .access-layout { display: block; }
  .access-illustration { display: none; }
  .access-panel { min-height: 100vh; padding: 44px 24px; }
  .access-content { max-width: 480px; }
  .dashboard-body { height: auto; overflow: auto; }
  .panel-header { height: auto; min-height: 76px; flex-wrap: wrap; padding: 13px; }
  .header-right { width: 100%; flex-wrap: wrap; justify-content: space-between; margin-top: 11px; }
  .panel-main { height: auto; min-height: calc(100vh - 130px); padding: 0 11px; }
  .panel-status-bar { gap: 8px; }
  .config-header-inner { flex-wrap: wrap; padding: 16px 18px; }
  .config-header-actions { width: 100%; justify-content: flex-start; }
  .config-header h1 { font-size: 20px; }
  .config-mark { width: 38px; height: 38px; }
  .config-main { padding: 20px 18px 40px; }
  .config-panel { padding: 20px; min-height: 0; }
  .config-page-navigation { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #unit-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #unit-form .logo-field, #unit-form .form-actions { grid-column: 1 / -1; }
  .auto-start-form { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 470px) {
  .access-panel { padding: 32px 20px; }
  .login-mark { width: 76px; height: 76px; margin-bottom: 20px; }
  .access-content h1 { font-size: 36px; }
  .login-copy { font-size: 16px; margin-bottom: 26px; }
  .access-entra-button { font-size: 14px; padding-left: 20px; padding-right: 30px; }
  .config-page-footer { flex-wrap: wrap; justify-content: center; }
  .config-page-footer span { order: -1; width: 100%; text-align: center; }
  .config-header-actions { gap: 7px; }
  .config-body .back-link, .config-body .header-button { padding: 7px 9px; font-size: 11px; }
  .config-main { padding: 16px 12px 30px; }
  .config-page-navigation { gap: 5px; padding: 8px; }
  .config-page-navigation a { gap: 6px; font-size: 12px; }
  .config-panel { padding: 17px 15px; }
  .section-heading { flex-wrap: wrap; }
  #unit-form { grid-template-columns: 1fr; }
  #unit-form .logo-field, #unit-form .form-actions { grid-column: 1; }
  .clock { font-size: 18px; }
  .current-date { font-size: 9px; }
  .panel-status-bar { height: auto; min-height: 36px; padding: 5px 0; flex-wrap: wrap; }
  .status-actions { width: 100%; justify-content: flex-end; }
  .unit-list-row { align-items: flex-start; flex-direction: column; }
  .global-settings-form { grid-template-columns: 1fr; }
  .global-settings-form .form-field label { min-height: 0; }
  .global-settings-form .form-actions { padding-top: 16px; }
}
