:root {
  --blue: #0f63e9;
  --blue-dark: #174886;
  --ink: #0b0f19;
  --muted: #5f6d7f;
  --line: #dbe4ef;
  --surface: #ffffff;
  --bg: #f5f7fb;
  --success: #dff7e7;
  --danger: #ffe1e6;
  --warning: #fff3c4;
  --shadow: 0 10px 30px rgba(20, 43, 77, .08);
}

* { box-sizing: border-box; }
html { min-height: 100%; overflow-x: hidden; }
body { overflow-x: hidden; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 400;
  letter-spacing: 0;
}
h1, h2, h3 { font-weight: 700; }
strong, b { font-weight: 400; }
a { color: var(--blue-dark); text-decoration: none; }
button, input, select, textarea { font: inherit; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  color: var(--ink);
  background: #fff;
}
textarea { resize: vertical; }
label { display: grid; gap: 7px; color: var(--blue-dark); font-weight: 400; font-size: 13px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 17px 18px; border-bottom: 1px solid #edf2f7; text-align: left; vertical-align: middle; }
th { color: #315d98; font-size: 12px; font-weight: 400; letter-spacing: .08em; text-transform: uppercase; background: #f8fbff; }
td { color: #15457f; }

.auth-page {
  background:
    url("../img/login-bg-gray.jpg"),
    url("../img/logo.png");
  background-size: cover, min(70vw, 780px) auto;
  background-position: center, center;
  background-repeat: no-repeat;
}
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: min(430px, 100%);
  padding: 34px;
  border-radius: 18px;
  color: var(--ink);
  background: rgba(255, 255, 255, .96);
  border: 1px solid rgba(255, 255, 255, .7);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .32);
  backdrop-filter: blur(8px);
}
.auth-logo {
  display: block;
  max-width: 230px;
  margin: 0 auto 24px;
  padding: 14px;
  border-radius: 14px;
  background: #fff;
}
.auth-card h1 { margin: 0 0 8px; font-size: 32px; }
.auth-card .muted { color: var(--muted); }
.auth-card label { color: var(--blue-dark); }
.auth-card a { color: var(--blue); }
.auth-card input {
  border-color: var(--line);
  color: var(--ink);
  background: #fff;
}
.auth-card input::placeholder { color: #8a98aa; }
.stack { display: grid; gap: 18px; }
.center-link { display: block; text-align: center; }

.app-page { display: flex; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: 300px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 28px 20px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.brand { display: grid; gap: 8px; color: var(--blue-dark); font-weight: 400; }
.brand img { width: 178px; height: auto; }
.brand span { font-size: 14px; }
.nav { display: grid; gap: 8px; overflow: auto; }
.nav a, .sidebar-footer a, .logout {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border: 0;
  border-radius: 8px;
  color: var(--blue-dark);
  background: transparent;
  font-weight: 400;
  text-align: left;
  cursor: pointer;
}
.nav a.active { color: var(--blue); background: #eaf2ff; }
.nav svg, .sidebar-footer svg, .topbar svg, .row-actions svg, .quick-list svg { width: 20px; height: 20px; stroke-width: 2.3; }
.sidebar-footer { margin-top: auto; display: grid; gap: 8px; padding-top: 16px; border-top: 1px solid #edf2f7; }
.logout { width: 100%; }

.main {
  min-width: 0;
  width: calc(100% - 300px);
  max-width: calc(100% - 300px);
  margin-left: 300px;
}
.topbar {
  min-height: 80px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px 30px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { margin: 0; font-size: 26px; }
.global-search {
  width: min(420px, 40vw);
  margin-left: auto;
  position: relative;
}
.global-search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: #7a8ca8; }
.global-search input { padding-left: 42px; background: #f8fbff; }
.user-chip { display: grid; gap: 2px; color: var(--blue-dark); font-size: 13px; }
.user-chip span { color: var(--muted); }
.content { min-width: 0; padding: 32px 30px 48px; overflow-x: hidden; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  margin-bottom: 24px;
}
.page-head h2 { margin: 4px 0 0; font-size: clamp(28px, 3vw, 40px); }
.eyebrow { color: #315d98; font-weight: 400; }
.actions, .form-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.primary, .secondary, .dark, .white-btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 11px 18px;
  font-weight: 400;
  cursor: pointer;
}
.primary { color: #fff; background: var(--blue); }
.secondary { color: var(--blue-dark); background: #fff; border-color: var(--line); }
.dark { color: #fff; background: var(--ink); }
.white-btn { color: var(--blue); background: #fff; }
.full { width: 100%; }
.inline { width: auto; }
.icon-btn { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--blue-dark); }
.mobile-only { display: none; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}
.metric {
  min-height: 150px;
  display: grid;
  align-content: center;
  gap: 12px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.metric svg { width: 42px; height: 42px; padding: 10px; border-radius: 8px; color: var(--blue); background: #eaf2ff; }
.metric span { color: var(--blue-dark); font-weight: 400; }
.metric strong { font-size: 32px; font-weight: 400; }
.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(320px, .95fr);
  gap: 30px;
}
.dashboard-grid-single { grid-template-columns: 1fr; }
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}
.section-title h2 { margin: 0; font-size: 24px; }
.table-card, .side-panel, .form-card, .detail-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow-x: auto;
  max-width: 100%;
}
.quick-list { display: grid; }
.quick-list a {
  display: flex;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid #edf2f7;
}
.quick-list span { display: grid; gap: 4px; }
.quick-list small { color: var(--muted); line-height: 1.35; }
.notice-band {
  margin-top: 30px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 28px 30px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, #146df4, #5039e6);
  box-shadow: var(--shadow);
}
.notice-band h2 { margin: 0 0 8px; }
.notice-band p { margin: 0; color: rgba(255, 255, 255, .86); }

.tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin: 0 0 22px;
}
.tabs a {
  min-height: 72px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--blue-dark);
  background: #fff;
  box-shadow: var(--shadow);
}
.tabs a.active {
  color: var(--blue);
  border-color: rgba(15, 99, 233, .45);
  background: #eaf2ff;
}
.tabs svg { width: 24px; height: 24px; }
.tabs span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.view-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.view-switch > div:first-child {
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.view-switch a {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border-radius: 6px;
  color: var(--blue-dark);
}
.view-switch a.active {
  color: #fff;
  background: var(--blue);
}
.month-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--blue-dark);
}
.month-nav a {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  background: #fff;
}
.month-nav svg { width: 18px; height: 18px; }
.calendar-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}
.calendar-weekdays span {
  padding: 12px;
  color: #315d98;
  background: #f8fbff;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  text-align: center;
}
.calendar-day {
  min-height: 142px;
  padding: 10px;
  border-right: 1px solid #edf2f7;
  border-bottom: 1px solid #edf2f7;
}
.calendar-day.empty { background: #f8fafc; }
.calendar-number {
  display: inline-flex;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}
.calendar-event {
  display: grid;
  gap: 3px;
  margin-bottom: 7px;
  padding: 8px;
  border-radius: 8px;
  color: var(--blue-dark);
  background: #eaf2ff;
}
.calendar-event span,
.calendar-event small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.calendar-event small { color: var(--muted); }

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  align-items: end;
  margin-bottom: 22px;
}
.search-combo {
  position: relative;
  width: 100%;
}
.combo-trigger {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 13px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
}
.combo-trigger span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.combo-trigger svg { width: 18px; height: 18px; color: var(--muted); }
.combo-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 40;
  width: min(360px, 100vw - 48px);
  max-height: 320px;
  display: none;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 18px 45px rgba(20, 43, 77, .18);
  overflow: auto;
}
.search-combo.open .combo-menu { display: grid; gap: 6px; }
.combo-search {
  position: sticky;
  top: 0;
  z-index: 1;
  margin-bottom: 4px;
  border-radius: 10px;
  background: #f8fbff;
}
.combo-option {
  width: 100%;
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--blue-dark);
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.combo-option:hover,
.combo-option.selected {
  color: var(--blue);
  background: #eaf2ff;
}
.form-card { padding: 24px; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.wide { grid-column: 1 / -1; }
.form-actions { margin-top: 22px; }
.detail-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  padding: 6px;
}
.section-block { margin-top: 28px; }
.compact-form { margin-bottom: 18px; }
.spaced { margin-top: 18px; }
.product-lines input,
.product-lines select { min-width: 150px; }
.totals-box {
  width: min(420px, 100%);
  margin: 18px 0 0 auto;
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}
.totals-box div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--blue-dark);
}
.detail-card div { display: grid; gap: 6px; padding: 16px; border-bottom: 1px solid #edf2f7; }
.detail-card span { color: var(--muted); text-transform: capitalize; }
.detail-card strong { overflow-wrap: anywhere; color: var(--blue-dark); }

.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  white-space: nowrap;
}
.row-actions a, .row-actions button {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--blue-dark);
  background: #fff;
  cursor: pointer;
}
.row-actions .text-action {
  width: auto;
  min-width: 132px;
  padding: 0 11px;
  gap: 7px;
  color: #105a2a;
  background: #effcf4;
  border-color: #c7f0d3;
  font-size: 12px;
  font-weight: 400;
}
.row-actions .text-action svg { width: 16px; height: 16px; }
.row-actions form { display: inline; }
.inline-select {
  width: auto;
  min-width: 138px;
  padding: 8px 32px 8px 10px;
  border-radius: 999px;
  color: var(--blue-dark);
  background: #f8fbff;
  font-size: 12px;
  font-weight: 400;
}
.inline-select.saved {
  border-color: #31c56f;
  background: #effcf4;
}
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 9px;
  border-radius: 999px;
  color: #105a2a;
  background: var(--success);
  font-size: 12px;
  font-weight: 400;
  text-transform: capitalize;
}
.badge.danger { color: #9f1239; background: var(--danger); }
.avatar {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 10px;
  border-radius: 50%;
  color: var(--blue-dark);
  background: #e7eef8;
  font-weight: 400;
}
.alert {
  margin-bottom: 18px;
  padding: 13px 15px;
  border-radius: 8px;
  font-weight: 400;
}
.alert.success { color: #105a2a; background: var(--success); }
.alert.danger { color: #9f1239; background: var(--danger); }
.muted { color: var(--muted); }
.center { text-align: center; }
.form-row { display: flex; gap: 12px; align-items: center; }
.between { justify-content: space-between; }
.checkline { display: flex; grid-template-columns: auto 1fr; align-items: center; gap: 8px; font-weight: 400; }
.checkline input { width: auto; }
.empty-state { max-width: 560px; margin: 80px auto; text-align: center; }

.print-page { padding: 30px; background: #fff; }
.print-page h1 { margin-top: 0; }

@media print {
  .print-page { padding: 0; }
}

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .mobile-only { display: inline-flex; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform .2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .main {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
  }
  .topbar { padding: 14px 18px; }
  .topbar h1 { font-size: 21px; }
  .global-search { display: none; }
  .user-chip { margin-left: auto; }
  .content { padding: 24px 18px 38px; }
  .page-head { align-items: start; flex-direction: column; }
  .metric-grid, .filters, .form-grid, .detail-card { grid-template-columns: 1fr; }
  .tabs { grid-template-columns: 1fr; }
  .calendar-weekdays { display: none; }
  .calendar-grid { grid-template-columns: 1fr; }
  .calendar-day { min-height: auto; }
  .view-switch { align-items: stretch; flex-direction: column; }
  .table-card { overflow-x: auto; }
  th, td { min-width: 150px; }
  .notice-band { align-items: start; flex-direction: column; }
}

@media (max-width: 520px) {
  .auth-card { padding: 26px 22px; }
  .actions, .form-actions, .form-row { width: 100%; flex-direction: column; align-items: stretch; }
  .primary, .secondary, .dark, .white-btn { width: 100%; }
  .metric { min-height: 130px; }
}
