:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eceff3;
  --surface-3: #f8f9fb;
  --border: #dfe3e8;
  --border-strong: #cbd1d9;
  --text: #181a1f;
  --muted: #69717d;
  --subtle: #8a929e;
  --blue: #246bfe;
  --blue-dark: #1859d9;
  --blue-soft: #e9f0ff;
  --teal: #17715f;
  --teal-soft: #e6f5f1;
  --amber: #965a00;
  --amber-soft: #fff4db;
  --red: #b83229;
  --red-soft: #fdecea;
  --violet: #6d4bc3;
  --violet-soft: #f0ebfc;
  --sidebar: 224px;
  --topbar: 64px;
  --radius: 8px;
  --shadow: 0 14px 38px rgba(24, 31, 43, 0.12);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Microsoft YaHei UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: var(--bg);
}

body {
  min-width: 320px;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: 0;
}

body.overlay-open {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  color: inherit;
}

button,
[role="button"] {
  -webkit-tap-highlight-color: transparent;
}

img {
  display: block;
  max-width: 100%;
}

.boot-screen {
  min-height: 100vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 2px solid #d8dde5;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 1fr auto;
  background:
    linear-gradient(180deg, #ffffff 0, #f5f7fa 72%, #edf0f4 100%);
}

.login-main {
  width: min(420px, calc(100% - 40px));
  margin: auto;
  padding: 42px 0 28px;
}

.login-brand {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  margin-bottom: 34px;
}

.login-brand img {
  width: 54px;
  height: 54px;
  border-radius: 12px;
  box-shadow: 0 7px 22px rgba(24, 26, 31, 0.13);
}

.login-brand h1 {
  margin: 0;
  font-size: 27px;
  line-height: 1.2;
  font-weight: 720;
}

.login-brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.login-panel {
  padding: 28px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 18px 48px rgba(35, 43, 56, 0.1);
}

.login-panel h2 {
  margin: 0 0 4px;
  font-size: 20px;
}

.login-panel > p {
  margin: 0 0 24px;
  color: var(--muted);
}

.login-footer {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  border-top: 1px solid rgba(203, 209, 217, 0.6);
  font-size: 12px;
}

.login-footer img {
  width: 15px;
  height: 15px;
  opacity: 0.65;
}

.field,
.check-field {
  display: grid;
  gap: 7px;
}

.field + .field {
  margin-top: 17px;
}

.field label,
.field-label {
  color: #3d444e;
  font-size: 13px;
  font-weight: 650;
}

.required::after {
  content: " *";
  color: var(--red);
}

.input,
.select,
.textarea {
  width: 100%;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.textarea {
  height: auto;
  min-height: 88px;
  padding-top: 10px;
  padding-bottom: 10px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(36, 107, 254, 0.12);
}

.input:disabled,
.select:disabled,
.textarea:disabled {
  color: var(--muted);
  background: var(--surface-2);
}

.input-wrap {
  position: relative;
}

.input-wrap > img {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 17px;
  height: 17px;
  transform: translateY(-50%);
  opacity: 0.56;
  pointer-events: none;
}

.input-wrap .input {
  padding-left: 38px;
}

.btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  color: #2d333c;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.btn:hover {
  background: var(--surface-3);
  border-color: #adb5c0;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn img,
.icon-btn img,
.nav-item img,
.page-icon img {
  width: 17px;
  height: 17px;
}

.btn-primary {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}

.btn-primary:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
}

.btn-danger {
  color: var(--red);
  border-color: #e5bbb7;
}

.btn-block {
  width: 100%;
}

.login-submit {
  margin-top: 24px;
  height: 43px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--surface-2);
  border-color: var(--border);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  width: var(--sidebar);
  display: flex;
  flex-direction: column;
  color: #e9edf4;
  background: #17191d;
  border-right: 1px solid #292d34;
}

.side-brand {
  height: var(--topbar);
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 18px;
  border-bottom: 1px solid #2a2e35;
}

.side-brand img {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.side-brand strong {
  display: block;
  font-size: 15px;
}

.side-brand span {
  display: block;
  margin-top: 1px;
  color: #929aa7;
  font-size: 11px;
}

.side-nav {
  flex: 1;
  display: grid;
  align-content: start;
  gap: 4px;
  padding: 18px 12px;
}

.nav-item {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  color: #aeb5c0;
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
}

.nav-item img {
  opacity: 0.8;
  filter: invert(79%) sepia(7%) saturate(307%) hue-rotate(177deg) brightness(92%);
}

.nav-item:hover {
  color: #fff;
  background: #24282f;
}

.nav-item.active {
  color: #fff;
  background: #2c333d;
  box-shadow: inset 3px 0 0 var(--blue);
}

.nav-item.active img {
  filter: invert(45%) sepia(98%) saturate(3868%) hue-rotate(214deg) brightness(102%);
}

.sidebar-footer {
  padding: 14px 12px 18px;
  border-top: 1px solid #2a2e35;
}

.user-brief {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 30px;
  align-items: center;
  gap: 9px;
  padding: 8px;
}

.user-avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: #fff;
  background: #343a44;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
}

.user-brief strong,
.user-brief span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-brief strong {
  color: #f2f4f7;
  font-size: 12px;
}

.user-brief span {
  color: #8f98a5;
  font-size: 11px;
}

.sidebar .icon-btn img {
  filter: invert(80%);
}

.workspace {
  grid-column: 2;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar);
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(240px, 420px) auto;
  align-items: center;
  gap: 18px;
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
}

.page-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.page-heading h1 {
  margin: 0;
  overflow: hidden;
  font-size: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-menu {
  display: none;
}

.global-search {
  position: relative;
}

.global-search img {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  opacity: 0.55;
}

.global-search input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 37px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
}

.global-search input:focus {
  background: #fff;
  border-color: var(--blue);
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
}

.cloud-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 650;
}

.cloud-state img {
  width: 16px;
  height: 16px;
}

.page-content {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.content-header {
  min-height: 44px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.content-header h2 {
  margin: 0;
  font-size: 21px;
}

.content-header p {
  margin: 5px 0 0;
  color: var(--muted);
}

.header-actions,
.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  min-height: 112px;
  display: grid;
  grid-template-columns: 1fr 34px;
  gap: 12px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
}

.metric-value {
  display: block;
  margin-top: 8px;
  font-size: 25px;
  line-height: 1.1;
  font-weight: 720;
}

.metric-note {
  display: block;
  margin-top: 9px;
  color: var(--muted);
  font-size: 11px;
}

.metric-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: var(--blue-soft);
  border-radius: 7px;
}

.metric-icon img {
  width: 18px;
  height: 18px;
}

.metric:nth-child(2) .metric-icon { background: var(--teal-soft); }
.metric:nth-child(3) .metric-icon { background: var(--amber-soft); }
.metric:nth-child(4) .metric-icon { background: var(--violet-soft); }

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(280px, 0.75fr);
  gap: 14px;
}

.analytics-grid {
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
}

.analytics-grid .data-table {
  min-width: 0;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-header {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
}

.panel-header h3 {
  margin: 0;
  font-size: 14px;
}

.panel-body {
  padding: 16px;
}

.table-panel {
  overflow: auto;
}

.data-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  height: 48px;
  padding: 8px 13px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  color: var(--muted);
  background: var(--surface-3);
  font-size: 11px;
  font-weight: 680;
  white-space: nowrap;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr[data-action] {
  cursor: pointer;
}

.data-table tbody tr[data-action]:hover td {
  background: #f7f9fc;
}

.primary-cell {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.primary-cell strong,
.primary-cell span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.primary-cell strong {
  font-size: 13px;
}

.primary-cell span {
  color: var(--muted);
  font-size: 11px;
}

.badge,
.flag,
.role-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 23px;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 11px;
  line-height: 1.25;
  white-space: nowrap;
}

.badge-neutral { color: #515965; background: #edf0f3; }
.badge-blue { color: var(--blue-dark); background: var(--blue-soft); }
.badge-teal { color: var(--teal); background: var(--teal-soft); }
.badge-amber { color: var(--amber); background: var(--amber-soft); }
.badge-red { color: var(--red); background: var(--red-soft); }
.badge-violet { color: var(--violet); background: var(--violet-soft); }

.flags {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.flag-rush { color: #a43d20; background: #ffebe3; }
.flag-vip { color: var(--violet); background: var(--violet-soft); }
.flag-hard { color: var(--red); background: var(--red-soft); }

.empty-state {
  min-height: 230px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  padding: 30px;
  color: var(--muted);
  text-align: center;
}

.empty-state img {
  width: 34px;
  height: 34px;
  opacity: 0.45;
}

.activity-list,
.summary-list {
  display: grid;
}

.activity-item,
.summary-item {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr);
  gap: 11px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}

.activity-item:last-child,
.summary-item:last-child {
  border-bottom: 0;
}

.activity-dot {
  width: 8px;
  height: 8px;
  margin-top: 6px;
  background: var(--blue);
  border-radius: 50%;
}

.activity-item strong,
.activity-item span {
  display: block;
}

.activity-item strong {
  font-size: 12px;
}

.activity-item span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.toolbar {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0;
}

.toolbar-search {
  width: min(360px, 100%);
}

.toolbar .select {
  width: auto;
  min-width: 132px;
}

.progress {
  width: 116px;
  display: grid;
  gap: 5px;
}

.progress-track {
  height: 6px;
  overflow: hidden;
  background: #e3e7ec;
  border-radius: 3px;
}

.progress-bar {
  height: 100%;
  background: var(--teal);
  border-radius: 3px;
}

.progress span {
  color: var(--muted);
  font-size: 10px;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(17, 22, 29, 0.28);
}

#drawer-root,
#modal-root {
  position: relative;
}

#drawer-root { z-index: 70; }
#modal-root { z-index: 110; }

.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 90;
  width: min(760px, calc(100% - 48px));
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: drawer-in 0.18s ease-out;
}

@keyframes drawer-in {
  from { transform: translateX(20px); opacity: 0; }
}

.drawer-header {
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 15px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
}

.drawer-header h2 {
  margin: 0;
  overflow: hidden;
  font-size: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-header p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.drawer-tabs {
  display: flex;
  gap: 3px;
  padding: 8px 14px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  min-width: max-content;
  height: 34px;
  padding: 0 11px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
}

.tab-btn:hover { background: var(--surface-2); }
.tab-btn.active { color: var(--blue-dark); background: var(--blue-soft); font-weight: 650; }

.drawer-body {
  min-height: 0;
  padding: 18px;
  overflow-y: auto;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
}

.detail-item {
  min-height: 66px;
  padding: 11px 13px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.detail-item span,
.detail-item strong {
  display: block;
}

.detail-item span {
  color: var(--muted);
  font-size: 11px;
}

.detail-item strong {
  margin-top: 5px;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.section-block {
  margin-top: 20px;
}

.section-block:first-child { margin-top: 0; }

.section-title {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.section-title h3 {
  margin: 0;
  font-size: 14px;
}

.inline-form,
.form-grid {
  display: grid;
  gap: 12px;
}

.inline-form {
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  align-items: end;
  padding: 13px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 7px;
}

.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid .full {
  grid-column: 1 / -1;
}

.form-section-title {
  margin-top: 6px;
  padding: 9px 0 7px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.form-section-title:first-child {
  margin-top: 0;
  padding-top: 0;
}

.checks {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.checkbox input {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
}

.copy-value {
  display: inline-flex;
  max-width: 100%;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  border-bottom: 1px dashed transparent;
  cursor: copy;
  text-align: left;
}

.copy-value:hover,
.copy-value:focus-visible {
  color: var(--blue-dark);
  border-bottom-color: currentColor;
  outline: 0;
}

.dual-inputs {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) 78px minmax(90px, 1fr) 70px;
  gap: 6px;
}

.dual-inputs .input,
.dual-inputs .select {
  min-width: 0;
}

.color-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 7px;
  vertical-align: -2px;
  border: 1px solid rgba(24, 26, 31, 0.18);
  border-radius: 3px;
}

.brand-color-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.brand-color {
  display: grid;
  justify-items: center;
  gap: 5px;
  color: var(--muted);
  cursor: pointer;
}

.brand-color input { position: absolute; opacity: 0; pointer-events: none; }

.brand-color span {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--swatch);
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 1px rgb(17 24 39 / 10%);
}

.brand-color input:checked + span {
  border-color: #111827;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #9bb7ee;
}

.birthday-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 16px;
  border-left: 3px solid #246bfe;
}
.birthday-panel p { margin: 4px 0 0; color: #697386; }

.customer-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.customer-portrait {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  border: 1px solid #dfe3e8;
  border-radius: 8px;
  object-fit: contain;
  background: #fff;
}

.customer-initials {
  display: grid;
  place-items: center;
  color: #246bfe;
  background: #eef4ff;
  font-size: 16px;
  font-weight: 700;
}

.export-image-grid,
.address-book {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px;
}

.export-image-option,
.address-record {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafc;
}

.address-record { align-items: flex-start; justify-content: space-between; }
.address-record > div { display: grid; gap: 3px; }
.address-record small { color: var(--muted); text-align: right; }
.address-field { min-height: 88px; }

.chart-panel { min-height: 250px; }
.column-chart {
  display: flex;
  align-items: end;
  gap: 12px;
  min-height: 180px;
  padding: 20px 22px 12px;
}
.chart-column { flex: 1; height: 140px; display: flex; flex-direction: column; align-items: center; justify-content: end; gap: 5px; }
.chart-column .chart-value { color: var(--muted); font-size: 11px; }
.chart-column .chart-bar { width: min(34px, 72%); min-height: 8px; background: #2f6fed; border-radius: 4px 4px 2px 2px; }
.chart-column small { color: var(--muted); }
.track-chart { display: grid; gap: 14px; padding: 24px; }
.chart-track-row { display: grid; grid-template-columns: 86px 1fr 28px; align-items: center; gap: 10px; }
.chart-track { height: 9px; background: #e8edf3; border-radius: 5px; overflow: hidden; }
.chart-track i { display: block; height: 100%; background: var(--chart-color); border-radius: 5px; }

.compact-metrics .metric-card {
  min-height: 106px;
}

.compact-metrics .metric-value {
  font-size: 22px;
}

.node-list {
  display: grid;
  gap: 8px;
}

.node-row {
  display: grid;
  grid-template-columns: 28px minmax(116px, 1.1fr) 112px minmax(100px, 1fr) 142px 142px;
  align-items: center;
  gap: 7px;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
}

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-3);
}

.segmented button {
  min-height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.segmented button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(20, 31, 46, 0.1);
}

.compact-check {
  min-height: 36px;
  white-space: nowrap;
}

.progress-summary {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.progress-compact {
  width: 150px;
}

.file-row {
  grid-template-columns: 28px 36px minmax(0, 1fr) auto;
}

.quote-row {
  grid-template-columns: 36px minmax(0, 1fr) auto;
}

.preview-choice {
  display: grid;
  place-items: center;
  width: 28px;
  height: 32px;
  cursor: pointer;
}

.preview-choice input {
  position: absolute;
  opacity: 0;
}

.preview-choice span {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
}

.preview-choice input:checked + span {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue);
}

.preview-choice img {
  width: 15px;
  height: 15px;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.permission-option {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 52px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
}

.permission-option span {
  display: grid;
  gap: 2px;
}

.permission-option small {
  color: var(--muted);
}

.date-input {
  position: relative;
  display: flex;
  min-width: 0;
}

.date-input > .input {
  padding-right: 38px;
}

.date-picker-button {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
}

.native-date-picker {
  position: absolute;
  width: 1px;
  height: 1px;
  right: 22px;
  bottom: 0;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 1180px) {
  .node-row {
    grid-template-columns: 28px minmax(130px, 1fr) 110px minmax(120px, 1fr);
  }

  .node-row .date-input {
    grid-column: span 2;
  }
}

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

  .progress-summary {
    align-items: flex-end;
    flex-direction: column;
  }
}

.node-row .input,
.node-row .select {
  height: 34px;
  padding: 0 8px;
  font-size: 12px;
}

.file-list,
.quote-list {
  display: grid;
  gap: 8px;
}

.file-row,
.quote-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  min-height: 58px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
}

.file-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border-radius: 6px;
}

.file-icon img { width: 17px; height: 17px; }

.row-actions {
  display: flex;
  align-items: center;
  gap: 3px;
}

.timeline {
  position: relative;
  display: grid;
  gap: 0;
}

.timeline::before {
  content: "";
  position: absolute;
  top: 14px;
  bottom: 20px;
  left: 5px;
  width: 1px;
  background: var(--border-strong);
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 12px;
  padding: 7px 0 14px;
}

.timeline-dot {
  z-index: 1;
  width: 11px;
  height: 11px;
  margin-top: 4px;
  background: #fff;
  border: 3px solid var(--blue);
  border-radius: 50%;
}

.timeline-item strong { display: block; font-size: 12px; }
.timeline-item p { margin: 3px 0; color: var(--muted); font-size: 12px; }
.timeline-item time { color: var(--subtle); font-size: 10px; }

.modal {
  position: fixed;
  inset: 50% auto auto 50%;
  z-index: 100;
  width: min(720px, calc(100% - 32px));
  max-height: calc(100vh - 48px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  transform: translate(-50%, -50%);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: modal-in 0.16s ease-out;
}

@keyframes modal-in {
  from { transform: translate(-50%, -48%) scale(0.99); opacity: 0; }
}

.modal-sm { width: min(440px, calc(100% - 32px)); }
.modal-lg { width: min(920px, calc(100% - 32px)); }

.modal-header,
.modal-footer {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
}

.modal-header { border-bottom: 1px solid var(--border); }
.modal-footer { justify-content: flex-end; border-top: 1px solid var(--border); }

.modal-header h2 {
  margin: 0;
  font-size: 17px;
}

.modal-body {
  min-height: 0;
  padding: 18px;
  overflow-y: auto;
}

.preview-modal {
  width: min(960px, calc(100% - 32px));
}

.preview-stage {
  min-height: 360px;
  display: grid;
  place-items: center;
  padding: 12px;
  background: #20242a;
}

.preview-stage img {
  max-width: 100%;
  max-height: calc(100vh - 190px);
  object-fit: contain;
}

.toast-root {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 150;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.toast {
  min-width: 260px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 11px 14px;
  color: #fff;
  background: #242932;
  border-radius: 6px;
  box-shadow: var(--shadow);
  animation: toast-in 0.18s ease-out;
}

.toast.error { background: #8e2923; }
.toast.success { background: #145e50; }

@keyframes toast-in {
  from { transform: translateY(8px); opacity: 0; }
}

.loading-line {
  height: 2px;
  overflow: hidden;
  background: var(--blue-soft);
}

.loading-line::after {
  content: "";
  display: block;
  width: 35%;
  height: 100%;
  background: var(--blue);
  animation: loading 1s ease-in-out infinite;
}

@keyframes loading {
  from { transform: translateX(-100%); }
  to { transform: translateX(360%); }
}

.muted { color: var(--muted); }
.danger { color: var(--red); }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.hidden { display: none !important; }

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .inline-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inline-form .btn { align-self: end; }
  .node-row {
    grid-template-columns: 26px minmax(130px, 1fr) 110px minmax(110px, 1fr) 38px;
  }
  .node-row .node-date { display: none; }
}

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .workspace { grid-column: 1; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu { display: inline-grid; }
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 0 14px;
  }
  .global-search { display: none; }
  .page-content { padding: 18px 14px; }
  .cloud-state span { display: none; }
}

@media (max-width: 620px) {
  .dual-inputs {
    grid-template-columns: minmax(0, 1fr) 72px;
  }

  .compact-metrics {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .login-panel { padding: 22px 18px; }
  .content-header { align-items: stretch; flex-direction: column; }
  .content-header .btn-primary { width: 100%; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric { min-height: 92px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-search { width: 100%; }
  .toolbar-actions { display: grid; grid-template-columns: 1fr 40px; }
  .toolbar .select { width: 100%; }
  .drawer { width: 100%; }
  .detail-grid,
  .form-grid,
  .inline-form { grid-template-columns: 1fr; }
  .node-row {
    grid-template-columns: 24px minmax(0, 1fr) 38px;
  }
  .node-row .node-status,
  .node-row .node-supplier,
  .node-row .node-date { grid-column: 2; display: block; }
  .node-row .node-save { grid-column: 3; grid-row: 1; }
  .modal { max-height: calc(100vh - 20px); }
  .top-actions .btn span { display: none; }
  .page-heading h1 { font-size: 16px; }
}
