:root {
  color: #2c2723;
  background: #f5f2ed;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --orange: #ef7f1a;
  --orange-dark: #c85f08;
  --orange-soft: #fff3e6;
  --ink: #27231f;
  --muted: #776f67;
  --line: #e6dfd7;
  --panel: #fff;
  --success: #17875d;
  --danger: #c74235;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; transform: none !important; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 5px; color: var(--orange-dark); font-size: 11px; font-weight: 800; letter-spacing: .14em; }

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #28231f; }
.login-card { width: min(460px, 100%); padding: 42px; border-radius: 20px; background: #fff; box-shadow: 0 30px 90px #0007; }
.login-card .brand-mark { margin-bottom: 24px; }
.login-card h1 { margin: 0; font-size: 28px; }
.login-card form { display: grid; gap: 16px; margin-top: 28px; }
.login-card label, #create-form label, .settings-form label { display: grid; gap: 7px; color: #554e47; font-size: 13px; font-weight: 650; }
input, select { width: 100%; border: 1px solid #dcd3ca; border-radius: 9px; padding: 11px 12px; color: var(--ink); background: #fff; outline: none; }
select { min-height: 43px; }
input:focus, select:focus { border-color: var(--orange); box-shadow: 0 0 0 3px #ef7f1a1c; }
input::placeholder { color: #aaa19a; }
.form-error { margin: 16px 0 0; color: var(--danger); font-size: 13px; }
.form-error.success { color: var(--success); }

.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; color: #fff; background: var(--orange); font-weight: 800; }
.brand-mark.small { width: 38px; height: 38px; border-radius: 11px; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 245px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 22px 16px; color: #fff; background: #28231f; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 24px; border-bottom: 1px solid #443d36; }
.brand strong, .brand small { display: block; }
.brand small { margin-top: 3px; color: #aaa098; font-size: 12px; }
nav { margin-top: 24px; display: grid; gap: 7px; }
.nav-item { width: 100%; border: 0; border-radius: 10px; padding: 12px 14px; color: #d8cec6; background: transparent; text-align: left; display: flex; gap: 12px; align-items: center; }
.nav-item:hover { color: #fff; background: #3a332e; }
.nav-item.active { color: #fff; background: var(--orange); }
.sidebar-bottom { margin-top: auto; padding: 14px 9px 4px; display: grid; gap: 10px; }
.smtp-status, .admin-identity { color: #bbb2aa; font-size: 12px; overflow-wrap: anywhere; }
.smtp-status::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: #4bd098; }
.smtp-status.warning::before { background: #f0a147; }
.text-button { padding: 0; border: 0; color: #d8cec6; background: transparent; text-align: left; font-size: 13px; }
.text-button:hover { color: #fff; }

main { min-width: 0; padding: 30px clamp(20px, 4vw, 54px) 60px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
h1 { margin: 0; font-size: clamp(25px, 3vw, 34px); }
.button { border: 1px solid var(--line); border-radius: 9px; padding: 9px 15px; color: var(--ink); background: #fff; transition: .15s ease; }
.button:hover { transform: translateY(-1px); border-color: #cfc4b9; }
.button.primary { border-color: var(--orange); color: #fff; background: var(--orange); }
.button.primary:hover { background: var(--orange-dark); }
.button.ghost { background: #faf8f5; }
.button.danger { color: var(--danger); border-color: #efc7c2; background: #fff7f6; }
.button.small { padding: 6px 10px; border-radius: 7px; font-size: 12px; }
.button.wide { width: 100%; padding-block: 11px; }
.notice { margin-bottom: 18px; padding: 12px 15px; border: 1px solid #f4cfaa; border-radius: 10px; color: #7b450e; background: var(--orange-soft); white-space: pre-wrap; }
.notice.error { color: #8f2d25; border-color: #efc3be; background: #fff3f2; }

.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.summary-grid article { padding: 18px 20px; border: 1px solid var(--line); border-radius: 13px; background: var(--panel); box-shadow: 0 8px 30px #49331d0a; }
.summary-grid span { display: block; color: var(--muted); font-size: 13px; }
.summary-grid strong { display: block; margin-top: 8px; font-size: 29px; }
.panel { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: 0 8px 30px #49331d0a; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 19px 22px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 0 0 4px; font-size: 18px; }
.panel-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 18px; border-bottom: 1px solid #eee8e2; text-align: left; vertical-align: middle; }
th { color: var(--muted); background: #fbfaf8; font-size: 12px; font-weight: 650; }
td { font-size: 13px; }
tbody tr:hover { background: #fffaf5; }
.user-cell strong, .user-cell small, .license-cell code, .license-cell small { display: block; }
.user-cell small, .license-cell small { margin-top: 4px; color: var(--muted); }
.license-cell code { color: #8d4b0c; }
.status { display: inline-flex; border-radius: 999px; padding: 4px 9px; color: #70502e; background: #f4ede6; font-size: 11px; font-weight: 700; white-space: nowrap; }
.status.active { color: #0c6a48; background: #e8f7f1; }
.status.expired { color: #95510d; background: var(--orange-soft); }
.status.revoked, .status.delivery_failed { color: #a4332a; background: #fff0ee; }
.row-actions { min-width: 210px; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.actions-column { text-align: right; }
.empty { padding: 70px 20px; text-align: center; color: var(--muted); }
.empty span { display: block; color: var(--orange); font-size: 34px; }
.empty h3 { margin: 12px 0 7px; color: var(--ink); }
.empty p { margin: 0; }

.forced-notice { margin-bottom: 18px; padding: 15px 18px; border: 1px solid #f1b779; border-radius: 12px; color: #713b08; background: #fff0dd; display: grid; gap: 4px; }
.forced-notice span { font-size: 13px; }
.settings-grid { display: grid; grid-template-columns: minmax(300px, .85fr) minmax(440px, 1.35fr); gap: 18px; align-items: start; }
.settings-panel { min-width: 0; overflow: hidden; }
.settings-form { padding: 22px; display: grid; gap: 17px; }
.settings-form fieldset { min-width: 0; margin: 0; padding: 0; border: 0; display: grid; gap: 17px; }
.settings-form fieldset:disabled { opacity: .55; }
.settings-form label > small { color: var(--muted); font-size: 11px; font-weight: 400; line-height: 1.45; }
.settings-form .inline-check { grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 9px; font-weight: 500; }
.settings-form .inline-check input { width: 17px; height: 17px; margin: 0; accent-color: var(--orange); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.settings-form .form-grid { align-items: start; }
.smtp-server-grid { grid-template-columns: minmax(0, 1fr) 150px; }
.smtp-sender-grid { grid-template-columns: minmax(0, 1fr) 150px; }
.smtp-test-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: end; padding-top: 3px; }
.smtp-test-row .button { min-height: 43px; }
.form-actions { display: flex; justify-content: flex-end; padding-top: 3px; }

dialog { width: min(560px, calc(100vw - 30px)); padding: 0; border: 0; border-radius: 15px; box-shadow: 0 28px 90px #2a1b0f42; }
dialog::backdrop { background: #211b17a8; backdrop-filter: blur(2px); }
#create-form { padding: 24px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; }
.dialog-heading h2 { margin: 0; }
.dialog-heading > button { border: 0; background: transparent; font-size: 28px; color: var(--muted); }
#create-form > label { margin-top: 15px; }
#create-form .form-grid { margin-top: 15px; }
.dialog-note { padding: 11px 12px; border-radius: 9px; color: #7b450e; background: var(--orange-soft); font-size: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }

@media (max-width: 1100px) {
  .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 82px minmax(0, 1fr); }
  .brand div, .nav-item { font-size: 0; }
  .brand { justify-content: center; padding-inline: 0; }
  .nav-item { justify-content: center; }
  .nav-item span { font-size: 18px; }
  .sidebar-bottom { padding-inline: 0; }
  .smtp-status, .admin-identity { font-size: 0; text-align: center; }
  .smtp-status::before { margin-right: 0; }
  .text-button { font-size: 11px; text-align: center; }
}

@media (max-width: 680px) {
  .login-card { padding: 30px 24px; }
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; flex-direction: row; align-items: center; padding: 10px 14px; }
  .brand { border: 0; padding: 0; }
  nav { margin: 0 0 0 auto; display: flex; }
  .nav-item { width: auto; padding: 10px 12px; }
  .sidebar-bottom { margin: 0 0 0 12px; display: block; }
  .smtp-status, .admin-identity { display: none; }
  main { padding: 20px 14px 40px; }
  .topbar { align-items: flex-end; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid, .smtp-server-grid, .smtp-sender-grid, .smtp-test-row { grid-template-columns: 1fr; }
  .panel-heading { align-items: flex-start; }
  .settings-form { padding: 18px; }
  .smtp-test-row .button, .form-actions .button { width: 100%; }
}

@media (max-width: 420px) {
  .brand .brand-mark { width: 34px; height: 34px; }
  .nav-item { padding: 9px 10px; }
  .text-button { font-size: 10px; }
  .summary-grid { gap: 9px; }
  .summary-grid article { padding: 14px; }
  .topbar { gap: 10px; }
  .topbar .button { padding-inline: 11px; }
}
