:root {
  --bg: #f3f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef3f8;
  --sidebar: #172335;
  --sidebar-2: #1d2b40;
  --sidebar-text: #d9e3ef;
  --sidebar-muted: #8ea0b5;
  --text: #1b2a3b;
  --text-2: #4e6072;
  --muted: #7c8b9b;
  --line: #dfe7ef;
  --line-strong: #ced9e5;
  --accent: #2d78d4;
  --accent-2: #1f66be;
  --accent-soft: #eaf3ff;
  --success: #22a06b;
  --success-soft: #e9f8f1;
  --warning: #c78a17;
  --warning-soft: #fff6df;
  --danger: #d84a4a;
  --danger-soft: #fff0f0;
  --shadow-sm: 0 1px 2px rgba(20, 34, 52, .04), 0 4px 14px rgba(20, 34, 52, .035);
  --shadow: 0 10px 30px rgba(29, 49, 76, .08), 0 2px 8px rgba(29, 49, 76, .04);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font: 14px/1.5 Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
svg.icon { width: 19px; height: 19px; fill: currentColor; display: block; flex: 0 0 auto; }
code { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 258px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px 14px 14px;
  background: linear-gradient(180deg, #172335 0%, #142031 100%);
  color: var(--sidebar-text);
  border-right: 1px solid rgba(255,255,255,.045);
}
.brand-block { display: flex; align-items: center; gap: 11px; padding: 3px 7px 20px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #3c8cf0, #2469bf);
  color: white; font-size: 19px; font-weight: 800;
  box-shadow: 0 8px 20px rgba(21, 103, 200, .28);
}
.brand-copy { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.brand-copy strong { font-size: 14.5px; letter-spacing: -.01em; color: #fff; }
.brand-copy span { margin-top: 3px; font-size: 10.5px; color: var(--sidebar-muted); text-transform: uppercase; letter-spacing: .08em; }
.server-pill {
  margin: 2px 5px 20px;
  padding: 11px 12px;
  display: flex; align-items: center; gap: 10px;
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 13px;
  background: rgba(255,255,255,.035);
}
.live-dot { width: 8px; height: 8px; border-radius: 99px; background: #42d392; box-shadow: 0 0 0 4px rgba(66,211,146,.09); }
.server-pill div { display: flex; flex-direction: column; min-width: 0; }
.server-pill strong { color: #edf5ff; font-size: 11.5px; font-weight: 650; }
.server-pill span:last-child { font-size: 10.5px; color: var(--sidebar-muted); }
.nav { display: flex; flex-direction: column; gap: 3px; min-height: 0; overflow-y: auto; }
.nav-label { padding: 7px 11px 5px; color: #71859b; font-size: 10px; font-weight: 750; text-transform: uppercase; letter-spacing: .12em; }
.nav-label.spaced { margin-top: 10px; }
.nav-link {
  min-height: 42px;
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px;
  border-radius: 11px;
  color: #becbdd;
  font-weight: 560;
  transition: background .16s ease, color .16s ease, transform .16s ease;
}
.nav-link:hover { background: rgba(255,255,255,.055); color: white; }
.nav-link.active {
  color: white;
  background: linear-gradient(90deg, rgba(55,128,218,.30), rgba(55,128,218,.13));
  box-shadow: inset 3px 0 0 #5fa2f2;
}
.nav-icon { width: 24px; height: 24px; display: grid; place-items: center; color: #8ca2bb; }
.nav-link.active .nav-icon { color: #7fb6f5; }
.sidebar-user {
  margin-top: auto;
  padding: 13px 8px 5px;
  display: grid; grid-template-columns: 34px minmax(0,1fr) 32px; align-items: center; gap: 9px;
  border-top: 1px solid rgba(255,255,255,.075);
}
.avatar, .top-avatar {
  border-radius: 999px; display: grid; place-items: center;
  font-weight: 750; color: #17599f; background: #dcecff;
}
.avatar { width: 34px; height: 34px; font-size: 13px; }
.sidebar-user-copy { min-width: 0; display: flex; flex-direction: column; }
.sidebar-user-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; color: #edf4fc; }
.sidebar-user-copy span { font-size: 10.5px; color: var(--sidebar-muted); }
.logout-icon { width: 32px; height: 32px; display: grid; place-items: center; color: #8799ad; border-radius: 9px; }
.logout-icon:hover { background: rgba(255,255,255,.06); color: #fff; }
.logout-icon .icon { width: 17px; height: 17px; }

.main { min-width: 0; }
.topbar {
  height: 68px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 0 34px;
  background: rgba(255,255,255,.93);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 20;
}
.crumb { display: flex; align-items: center; gap: 8px; min-width: 0; color: #8491a0; font-size: 12.5px; }
.crumb b { color: #bcc6d0; font-weight: 400; }
.crumb strong { color: #415467; font-weight: 650; }
.topbar-right { display: flex; align-items: center; gap: 13px; }
.top-time { color: #8795a4; font-size: 12px; }
.top-avatar { width: 32px; height: 32px; font-size: 12px; }
.content { width: min(1480px, 100%); padding: 34px 38px 54px; }

.page-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; margin: 0 0 25px; }
.page-intro h1 { margin: 2px 0 5px; font-size: clamp(26px, 3vw, 36px); line-height: 1.15; letter-spacing: -.035em; color: #172639; }
.page-intro p { max-width: 720px; margin: 0; color: #718092; font-size: 14px; }
.eyebrow { color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.intro-actions { display: flex; flex-wrap: wrap; gap: 9px; justify-content: flex-end; }

.btn {
  min-height: 40px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 14px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: linear-gradient(180deg, #347fd9, #266fc8);
  color: #fff;
  font-weight: 680;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(37,104,187,.16);
  transition: transform .14s ease, box-shadow .14s ease, background .14s ease;
}
.btn:hover { transform: translateY(-1px); background: linear-gradient(180deg, #2f79d2, #1f66bc); box-shadow: 0 5px 12px rgba(37,104,187,.19); }
.btn:active { transform: translateY(0); }
.btn .icon { width: 16px; height: 16px; }
.btn.secondary {
  color: #38516c;
  background: #fff;
  border-color: #ced9e4;
  box-shadow: 0 1px 2px rgba(20,34,52,.035);
}
.btn.secondary:hover { background: #f7fafd; border-color: #b9c8d7; }
.btn.danger { color: white; background: var(--danger); border-color: var(--danger); }
.small-btn { min-height: 34px; padding: 6px 10px; font-size: 12.5px; }

.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card {
  min-height: 116px;
  display: flex; align-items: center; gap: 15px;
  padding: 18px 19px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.stat-icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 14px; color: var(--accent); background: var(--accent-soft); }
.stat-icon .icon { width: 22px; height: 22px; }
.stat-copy { min-width: 0; display: grid; grid-template-columns: auto auto; column-gap: 9px; align-items: baseline; }
.stat-copy > span { grid-column: 1 / -1; color: #637386; font-size: 12px; font-weight: 650; }
.stat-copy > strong { color: #1b2a3b; font-size: 27px; line-height: 1.05; letter-spacing: -.035em; }
.stat-copy > small { color: #94a0ac; font-size: 11px; align-self: center; }

.workspace-card, .panel, .card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.workspace-card { overflow: hidden; }
.workspace-head {
  min-height: 70px;
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 13px 16px 13px 19px;
  border-bottom: 1px solid var(--line);
}
.segmented { display: flex; align-items: center; gap: 3px; padding: 4px; background: #eef3f8; border-radius: 11px; }
.segment {
  min-height: 35px; padding: 7px 11px; border: 0; border-radius: 8px;
  color: #607286; background: transparent; cursor: pointer; font-weight: 650;
}
.segment span { margin-left: 5px; min-width: 20px; padding: 1px 6px; display: inline-flex; justify-content: center; border-radius: 99px; background: rgba(91,114,139,.10); font-size: 11px; }
.segment.active { color: #224769; background: #fff; box-shadow: 0 1px 4px rgba(35,57,83,.12); }
.segment.active span { color: #286cc0; background: #e8f2ff; }
.mail-filters { display: flex; align-items: center; gap: 9px; }
.searchbox {
  width: min(320px, 34vw); min-height: 38px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 11px;
  border: 1px solid #d3dee9; border-radius: 10px; background: #fff; color: #8797a7;
}
.searchbox:focus-within { border-color: #6da4e3; box-shadow: 0 0 0 3px rgba(48,124,213,.10); }
.searchbox .icon { width: 16px; height: 16px; }
.searchbox input { width: 100%; min-width: 0; padding: 0; border: 0; outline: 0; background: transparent; box-shadow: none; }
.mail-filters select { width: auto; min-width: 175px; min-height: 38px; padding: 7px 34px 7px 10px; }
.mail-tab-panel { display: none; }
.mail-tab-panel.active { display: block; }

.object-table-wrap { overflow-x: auto; }
.object-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.object-table th {
  padding: 11px 15px;
  text-align: left;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
  color: #8290a0;
  font-size: 10.5px;
  font-weight: 780;
  letter-spacing: .065em;
  text-transform: uppercase;
  white-space: nowrap;
}
.object-table th:first-child, .object-table td:first-child { padding-left: 20px; }
.object-table th:last-child, .object-table td:last-child { padding-right: 18px; }
.object-table td {
  padding: 13px 15px;
  border-bottom: 1px solid #edf1f5;
  vertical-align: middle;
  color: #425468;
}
.object-table tbody tr:last-child td { border-bottom: 0; }
.object-table tbody tr { transition: background .13s ease; }
.object-table tbody tr:hover { background: #fbfdff; }
.object-table tr[hidden] { display: none; }
.mail-identity { min-width: 260px; display: flex; align-items: center; gap: 11px; }
.mail-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; color: #347ad0; background: #edf5ff; }
.mail-icon.forward-icon { color: #7956c9; background: #f1edff; }
.mail-icon .icon { width: 17px; height: 17px; }
.mail-identity > div:last-child { min-width: 0; display: flex; flex-direction: column; }
.mail-identity strong { color: #213448; font-size: 13.5px; font-weight: 680; word-break: break-word; }
.mail-identity span { margin-top: 2px; color: #96a2af; font-size: 11px; word-break: break-word; }
.login-code { display: inline-flex; padding: 4px 7px; border: 1px solid #e0e7ef; border-radius: 7px; background: #f7f9fb; color: #5b6c7d; font-size: 11.5px; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 650; }
.status-pill i { width: 7px; height: 7px; border-radius: 99px; background: currentColor; }
.status-pill.active { color: #168052; background: var(--success-soft); }
.status-pill.paused { color: #9c711c; background: var(--warning-soft); }
.status-pill.blocked { color: #b13e3e; background: var(--danger-soft); }
.chip-list { display: flex; flex-wrap: wrap; gap: 5px; }
.soft-chip { display: inline-flex; max-width: 320px; padding: 4px 8px; border: 1px solid #dce5ee; border-radius: 99px; background: #f7f9fb; color: #647688; font-size: 11px; word-break: break-word; }
.target-chip { color: #5d4f94; background: #f8f6ff; border-color: #e3ddf7; }
.empty-value { color: #a2aeba; }
.action-col { width: 125px; }
.actions { text-align: right; white-space: nowrap; }
.icon-btn {
  min-height: 34px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 9px; border: 1px solid #d6e0ea; border-radius: 9px; background: #fff; color: #4e6276; font-size: 12px; font-weight: 650;
}
.icon-btn:hover { color: #1f65b5; border-color: #b7cee7; background: #f8fbff; }
.icon-btn .icon { width: 14px; height: 14px; }
.filter-empty, .empty-state {
  min-height: 220px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 30px; color: #8190a0;
}
.empty-state .icon, .filter-empty .icon { width: 32px; height: 32px; margin-bottom: 12px; color: #9db4cb; }
.empty-state strong, .filter-empty strong { color: #405367; font-size: 14px; }
.empty-state span, .filter-empty span { max-width: 430px; margin-top: 4px; font-size: 12px; }

.panel { padding: 20px; }
.panel.narrow { max-width: 840px; }
.panel h2 { margin: 0 0 5px; font-size: 20px; letter-spacing: -.02em; }
.panel-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 16px; }
.panel-title h2 { margin-bottom: 2px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.card { display: flex; flex-direction: column; gap: 5px; min-height: 145px; padding: 18px; }
.card strong { font-size: 24px; }
.card.featured { border-color: #bfd6ee; background: linear-gradient(145deg, #fff, #f4f9ff); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.badge { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 99px; color: #3c6f9f; background: #edf5ff; font-size: 11px; font-weight: 650; }
.ok-badge { color: #1e8056; background: #ebf8f2; }

input, select, textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid #ccd8e4;
  border-radius: 10px;
  background: #fff;
  color: #203246;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
input::placeholder, textarea::placeholder { color: #a9b3be; }
input:focus, select:focus, textarea:focus { border-color: #6ba2e1; box-shadow: 0 0 0 3px rgba(45,120,212,.10); }
textarea { min-height: 120px; resize: vertical; }
.field { margin-bottom: 15px; }
.field label { display: block; margin-bottom: 6px; color: #465a6e; font-size: 12px; font-weight: 680; }
.hint { margin-top: 5px; color: #8d9aaa; font-size: 11.5px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-actions { margin-top: 18px; }
.email-compose { display: grid; grid-template-columns: minmax(160px,1fr) 32px minmax(220px,1.25fr); align-items: end; gap: 8px; }
.email-compose .at { padding-bottom: 22px; text-align: center; color: #8796a6; font-size: 20px; }
.input-action { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; }
.checks { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
.check { display: flex; align-items: center; gap: 8px; padding: 10px 11px; border: 1px solid #e0e7ee; border-radius: 10px; background: #fafbfd; color: #516477; }
.check input { width: auto; min-height: 0; }
.preset { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 14px 15px; margin-bottom: 18px; border: 1px solid #d6e4f2; border-radius: 12px; background: #f6faff; }
.backline { margin: 0 0 15px; }
.backline a { display: inline-flex; color: #3476bf; font-weight: 620; }
.backline a:hover { text-decoration: underline; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 9px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: #788898; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; }

.flash { display: flex; align-items: center; gap: 9px; padding: 11px 13px; margin-bottom: 18px; border-radius: 11px; border: 1px solid #d4e7db; background: #f1fbf5; color: #246b49; }
.flash .icon { width: 17px; height: 17px; }
.ok-flash { border-color: #cee7d8; background: #effaf4; }
.error { color: #c94545; }
.error-box { padding: 12px 14px; border: 1px solid #efc6c6; border-radius: 11px; background: #fff4f4; color: #a33d3d; }

.login {
  width: min(440px, calc(100% - 32px));
  margin: 10vh auto 0;
  padding: 28px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.login:before { content: "HMF"; width: 44px; height: 44px; margin-bottom: 18px; display: grid; place-items: center; border-radius: 13px; color: #fff; background: linear-gradient(145deg,#3c8cf0,#2469bf); font-weight: 800; }
.login h1 { margin: 0 0 4px; font-size: 25px; letter-spacing: -.03em; }
.login .btn { width: 100%; margin-top: 5px; }

@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 82px minmax(0,1fr); }
  .sidebar { padding-inline: 10px; }
  .brand-block { justify-content: center; padding-inline: 0; }
  .brand-copy, .server-pill div, .sidebar-user-copy, .nav-link > span:last-child, .nav-label { display: none; }
  .server-pill { justify-content: center; padding: 12px; }
  .nav-link { justify-content: center; padding-inline: 9px; }
  .sidebar-user { grid-template-columns: 1fr; justify-items: center; }
  .logout-icon { display: none; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 800px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; display: block; padding: 12px; }
  .brand-block { justify-content: flex-start; padding-bottom: 10px; }
  .brand-copy { display: flex; }
  .server-pill, .sidebar-user, .nav-label { display: none; }
  .nav { flex-direction: row; overflow-x: auto; gap: 4px; }
  .nav-link { min-width: max-content; min-height: 38px; justify-content: flex-start; }
  .nav-link > span:last-child { display: inline; }
  .topbar { position: static; height: 56px; padding: 0 18px; }
  .crumb span, .crumb b, .top-time { display: none; }
  .content { padding: 24px 18px 40px; }
  .page-intro { align-items: flex-start; flex-direction: column; }
  .intro-actions { justify-content: flex-start; }
  .stat-grid { grid-template-columns: 1fr; }
  .workspace-head { align-items: stretch; flex-direction: column; }
  .mail-filters { width: 100%; }
  .searchbox { width: 100%; }
  .mail-filters select { min-width: 150px; }
  .form-grid, .email-compose, .checks { grid-template-columns: 1fr; }
  .email-compose .at { display: none; }
  .input-action { grid-template-columns: 1fr; }
  .panel-title, .preset { align-items: stretch; flex-direction: column; }
}

@media (max-width: 560px) {
  .content { padding-inline: 12px; }
  .page-intro h1 { font-size: 27px; }
  .intro-actions { width: 100%; }
  .intro-actions .btn { flex: 1 1 100%; }
  .workspace-head { padding: 12px; }
  .segmented { width: 100%; }
  .segment { flex: 1; }
  .mail-filters { flex-direction: column; }
  .mail-filters select { width: 100%; }
  .object-table th:nth-child(2), .object-table td:nth-child(2), .object-table th:nth-child(4), .object-table td:nth-child(4) { display: none; }
  .mail-identity { min-width: 210px; }
}
