:root {
  --ink: #14211f;
  --muted: #6b7875;
  --line: #dfe7e4;
  --paper: #f5f7f5;
  --card: #ffffff;
  --accent: #0f766e;
  --accent-deep: #115e59;
  --accent-soft: #dff4ef;
  --warm: #f5b942;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(22, 45, 40, .08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.view-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
select { font: inherit; color: var(--ink); background: #fff; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; min-height: 42px; }
.connection-note { background: #fff7e3; color: #745019; padding: 14px 18px; border: 1px solid #ecd8a8; border-radius: 12px; font-size: 14px; line-height: 1.7; }
.section-tabs { display: flex; gap: 8px; padding: 6px; border: 1px solid var(--line); border-radius: 14px; background: #eaf0ed; margin: 24px 0 16px; width: fit-content; }
.section-tabs button { color: var(--muted); background: transparent; }
.section-tabs button.active { color: #fff; background: var(--accent); }
.inventory-filters { display: grid; grid-template-columns: 1.6fr 1fr 1fr auto; gap: 12px; padding: 16px 26px 22px; }
.event-detail { margin-top: 24px; }
.new-badge { display: inline-block; padding: 6px 10px; border-radius: 8px; background: #fff0d6; color: #955500; font-size: 12px; font-weight: 700; }
.status-label { color: var(--muted); font-size: 12px; }
.compact { padding: 8px 10px; font-size: 12px; }
.mailbox-subline { display: block; color: var(--muted); margin-top: 5px; font-size: 12px; }
td.service-projects { min-width: 150px; max-width: 300px; white-space: normal; line-height: 1.65; }
#library-view table { min-width: 1550px; }
#library-view th { white-space: nowrap; }
#library-view td.service-projects { min-width: 180px; }
#library-view td.time { min-width: 155px; }
#action-result { color: var(--accent); font-size: 14px; line-height: 1.7; }
.checkbox-label { display: flex !important; flex-direction: row; align-items: center; gap: 10px; font-weight: 400 !important; line-height: 1.6; }
.checkbox-label input { width: 18px; height: 18px; flex-shrink: 0; }
.form-error { color: var(--danger); font-size: 13px; }
.imap-actions { flex-wrap: wrap; }
#server-dialog { width: min(850px, calc(100% - 32px)); max-height: calc(100vh - 40px); overflow-y: auto; }
.routing-section { border-top: 1px solid var(--line); margin-top: 24px; padding-top: 16px; }
.routing-section h3 { margin: 0 0 10px; }
.routing-section td { padding: 12px 10px; }
.routing-section select { max-width: 310px; }
#imap-connection-status { font-size: 13px; color: var(--accent); line-height: 1.7; }
#imap-fingerprint { font-family: Consolas, monospace; font-size: 12px; }
@media (max-width: 720px) { .inventory-filters { grid-template-columns: 1fr; padding: 16px; } .view-actions { justify-content: flex-start; } .hero { flex-direction: column; } }
body {
  margin: 0; color: var(--ink); background: var(--paper);
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
button, input { font: inherit; }
button {
  border: 0; border-radius: 10px; padding: 11px 18px; color: #fff;
  background: var(--accent); font-weight: 700; cursor: pointer;
}
button:hover { background: var(--accent-deep); }
button:disabled { opacity: .45; cursor: not-allowed; }
.secondary, .ghost { color: var(--ink); background: #fff; border: 1px solid var(--line); }
.secondary:hover, .ghost:hover { background: #eef3f1; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: .16em; }
.brand-mark {
  display: grid; place-items: center; width: 58px; height: 58px; border-radius: 18px;
  color: #fff; background: linear-gradient(145deg, #14a195, #0d5d56); font-size: 27px; font-weight: 900;
  box-shadow: 0 14px 30px rgba(15, 118, 110, .24);
}
.brand-mark.small { width: 38px; height: 38px; border-radius: 11px; font-size: 18px; }

.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center;
  height: 72px; padding: 0 max(24px, calc((100vw - 1440px) / 2)); background: rgba(255,255,255,.94);
  border-bottom: 1px solid var(--line); backdrop-filter: blur(12px);
}
.brand, .account { display: flex; align-items: center; gap: 12px; }
.brand div { display: grid; gap: 2px; }
.brand span { color: var(--muted); font-size: 11px; letter-spacing: .08em; }
.account { color: var(--muted); font-size: 14px; }
.account a { color: var(--accent); text-decoration: none; margin-left: 8px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #22a06b; box-shadow: 0 0 0 4px #dcfce7; }
.dashboard { width: min(1440px, calc(100% - 48px)); margin: 0 auto; padding: 48px 0 72px; }
.hero { display: flex; align-items: end; justify-content: space-between; margin-bottom: 28px; }
.hero h1 { margin: 0 0 8px; font-size: clamp(30px, 4vw, 48px); letter-spacing: -.04em; }
.hero p:last-child { margin: 0; color: var(--muted); }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  position: relative; overflow: hidden; display: grid; min-height: 150px; padding: 22px;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
}
.stat-card span, .stat-card small { color: var(--muted); }
.stat-card strong { align-self: center; font-size: 38px; letter-spacing: -.04em; }
.stat-card.accent { color: #fff; background: linear-gradient(145deg, #0f766e, #164e4a); border-color: transparent; }
.stat-card.accent::after {
  content: ""; position: absolute; width: 140px; height: 140px; border: 28px solid rgba(255,255,255,.08);
  border-radius: 50%; right: -45px; top: -50px;
}
.stat-card.accent span, .stat-card.accent small { color: rgba(255,255,255,.72); }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 24px 26px 12px; }
.panel-head h2 { margin: 0; font-size: 24px; }
.result-count { padding: 7px 11px; color: var(--accent-deep); background: var(--accent-soft); border-radius: 999px; font-weight: 700; font-size: 13px; }
.customer-import { display: flex; align-items: center; gap: 10px; }
.customer-import { flex-wrap: wrap; justify-content: flex-end; }
.action-link { padding: 11px 18px; border-radius: 10px; text-decoration: none; font-size: 14px; font-weight: 700; }
.customer-directory { margin-top: 24px; }
.customer-directory summary { padding: 22px 26px; cursor: pointer; font-weight: 700; }
.customer-directory summary span { display: inline-block; margin-left: 12px; font-weight: 400; }
.directory-search { display: flex; gap: 10px; padding: 0 26px 20px; }
.directory-search input { max-width: 440px; }
dialog { width: min(480px, calc(100% - 32px)); padding: 26px; color: var(--ink); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(15, 40, 37, .42); }
.customer-form { display: grid; gap: 18px; }
.customer-form label { display: grid; gap: 8px; font-size: 14px; font-weight: 700; }
.customer-form p { margin: 0; line-height: 1.7; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-head h2 { margin: 0; font-size: 22px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }
#customer-form-error { color: var(--danger); font-size: 13px; }
@media (max-width: 720px) { .panel-head { align-items: flex-start; flex-direction: column; gap: 16px; } .customer-import { justify-content: flex-start; } }
.customer-import input[hidden] { display: none; }
.panel-note { margin: 8px 26px; color: var(--muted); font-size: 12px; line-height: 1.7; }
#import-result { color: var(--accent); margin-left: 10px; }
.webmail-link, .webmail-button { display: inline-block; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--accent); background: var(--accent-soft); font-size: 13px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.webmail-link:hover { background: #c9eae1; }
.webmail-button:disabled { color: #62716d; background: #edf1ef; opacity: 1; cursor: not-allowed; }
.webmail-hint { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
th:last-child, td:last-child { position: sticky; right: 0; background: var(--card); box-shadow: -5px 0 9px rgba(22,45,40,.04); }
.muted { color: var(--muted); font-size: 12px; }
.filters {
  display: grid; grid-template-columns: 1.5fr repeat(4, 1fr) auto; gap: 12px; align-items: end;
  padding: 14px 26px 24px; border-bottom: 1px solid var(--line);
}
.filters label { display: grid; gap: 7px; min-width: 0; color: var(--muted); font-size: 12px; font-weight: 700; }
input {
  width: 100%; height: 42px; padding: 0 12px; color: var(--ink); background: #fafcfb;
  border: 1px solid var(--line); border-radius: 10px; outline: none;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: #fff; }
.filter-actions { display: flex; gap: 8px; }
.table-wrap { overflow-x: auto; }
.health-card { text-align: left; display: grid; gap: 6px; cursor: pointer; color: var(--ink); }
.health-card:hover { border-color: var(--accent); background: #f2faf7; }
.business-card { text-align: left; color: var(--ink); }
.business-card:hover { border-color: var(--accent); background: #edf7f3; }
.business-card.accent:hover { background: var(--accent-deep); }
.monitor-overview { margin: 18px 0; }
.monitor-overview > summary { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 18px 22px; cursor: pointer; font-weight: 700; }
.monitor-overview > summary::before { content: '▸'; color: var(--accent); }
.monitor-overview[open] > summary::before { content: '▾'; }
.summary-hint { margin-left: auto; color: var(--accent); font-size: 12px; font-weight: 400; }
.mailbox-technical { margin-top: 7px; max-width: 300px; white-space: normal; }
.mailbox-technical summary { color: var(--accent); cursor: pointer; font-size: 12px; }
.health-grid { grid-template-columns: repeat(3, 1fr); margin: 18px 22px; }
.health-grid .stat-card { min-height: 120px; box-shadow: none; }
.health-grid .stat-card strong { font-size: 30px; }
.monitor-overview .diagnostics { margin-top: 18px; border-top: 1px solid var(--line); }
.stat-card { min-height: 120px; }
.connection-note.good { color: #155e52; background: #edf8f3; border-color: #cde7da; }
.connection-note.bad { color: var(--danger); background: #fff0ee; border-color: #ffd3cd; }
@media (max-width: 720px) { .health-grid { grid-template-columns: repeat(2, 1fr); margin: 14px; gap: 10px; } .monitor-overview > summary { padding: 15px; } }
.warning-card strong { color: #a44c20; }
.diagnostics summary { padding: 20px; cursor: pointer; font-weight: 700; }
.diagnostics summary span { font-weight: 400; margin-left: 12px; }
.diagnostic-table td { white-space: normal; min-width: 110px; vertical-align: top; }
.diagnostic-table { min-width: 1450px; table-layout: fixed; }
.diagnostic-table th:first-child { width: 220px; }
.diagnostic-table th:nth-child(7) { width: 320px; }
.diagnostic-table small { display: block; margin-top: 6px; }
.batch-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--line); }
.batch-toolbar label { display: flex; align-items: center; gap: 8px; }
.notification-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 18px; }
.notification-toolbar label { display: flex; gap: 6px; align-items: center; }
.notification-toolbar input[type=checkbox] { width: 16px; height: 16px; }
.batch-toolbar input[type=checkbox], .mailbox-select { width: 16px; height: 16px; vertical-align: middle; margin-right: 8px; }
.health-overdue, .health-retrying, .health-error { color: #a44c20; font-weight: 700; }
.health-healthy { color: var(--accent); font-weight: 700; }
#library-search { grid-template-columns: repeat(3, minmax(130px, 1fr)); }
@media (max-width: 720px) { #library-search { grid-template-columns: 1fr; } }
table { width: 100%; border-collapse: collapse; }
th { padding: 13px 20px; color: var(--muted); background: #f8faf9; font-size: 12px; text-align: left; letter-spacing: .04em; }
td { max-width: 420px; padding: 17px 20px; border-top: 1px solid var(--line); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tbody tr:hover { background: #fbfdfc; }
td.subject { color: #31423e; }
td.time { color: var(--muted); font-variant-numeric: tabular-nums; }
td.empty { height: 180px; color: var(--muted); text-align: center; }
td.error { color: var(--danger); }
.pagination { display: flex; justify-content: center; align-items: center; gap: 16px; padding: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }

.login-page { min-height: 100vh; background: #0f2825; }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: 1.2fr .8fr; }
.login-brand {
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: center;
  padding: clamp(48px, 8vw, 140px); color: #fff; background:
    radial-gradient(circle at 20% 20%, rgba(245,185,66,.22), transparent 30%),
    linear-gradient(145deg, #123d38, #0c211f);
}
.login-brand::after {
  content: ""; position: absolute; width: 450px; height: 450px; right: -180px; bottom: -190px;
  border: 80px solid rgba(255,255,255,.04); border-radius: 50%;
}
.login-brand .eyebrow { margin-top: 34px; color: var(--warm); }
.login-brand h1 { margin: 0 0 18px; font-size: clamp(42px, 6vw, 74px); letter-spacing: -.05em; }
.login-brand p:last-child { max-width: 520px; color: rgba(255,255,255,.65); font-size: 18px; line-height: 1.8; }
.login-card { display: flex; flex-direction: column; justify-content: center; padding: clamp(36px, 8vw, 110px); background: #fff; }
.login-card h2 { margin: 0 0 30px; font-size: 34px; }
.login-card form, .login-card label { display: grid; gap: 10px; }
.login-card form { gap: 20px; }
.login-card label { color: var(--muted); font-size: 13px; font-weight: 700; }
.login-card input { height: 50px; }
.login-card button { height: 50px; margin-top: 6px; }
.alert { margin-bottom: 20px; padding: 12px 14px; color: var(--danger); background: #fff0ee; border: 1px solid #ffd3cd; border-radius: 10px; }

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .filters { grid-template-columns: repeat(3, 1fr); }
  .search-field { grid-column: span 2; }
}
@media (max-width: 720px) {
  .topbar { padding: 0 16px; }
  .brand div { display: none; }
  .dashboard { width: calc(100% - 24px); padding-top: 28px; }
  .hero { align-items: start; gap: 18px; }
  .hero .secondary { padding: 10px 12px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { min-height: 125px; padding: 17px; }
  .stat-card strong { font-size: 30px; }
  .filters { grid-template-columns: 1fr; padding: 14px 16px 20px; }
  .search-field { grid-column: auto; }
  .filter-actions button { flex: 1; }
  .panel-head { padding: 20px 16px 8px; }
  th, td { padding-left: 14px; padding-right: 14px; }
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { min-height: 38vh; padding: 40px 28px; }
  .login-brand h1 { font-size: 42px; }
  .login-brand p:last-child { font-size: 15px; }
  .login-card { min-height: 62vh; padding: 44px 28px; }
}
