.icon-button {
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text-muted);
  display: grid;
  place-items: center;
  font-size: 18px;
}
.icon-button:hover { background: var(--color-surface-2); color: var(--color-text); }
.notification-button { position: relative; background: var(--color-surface-1); border-color: var(--color-border); }
.notification-button i { position: absolute; top: 8px; right: 8px; width: 6px; height: 6px; background: var(--color-warning); border-radius: 50%; }

.primary-button, .secondary-button, .ghost-button, .mini-button, .text-button {
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 13px;
}
.primary-button { min-height: 40px; padding: 0 16px; border: 0; background: var(--color-primary); color: var(--color-on-primary); display: inline-flex; align-items: center; gap: 6px; }
.primary-button:hover { background: var(--color-primary-hover); }
.primary-button:disabled { opacity: 0.6; cursor: not-allowed; }
.secondary-button { min-height: 40px; padding: 0 14px; border: 1px solid var(--color-border); background: var(--color-surface-1); }
.secondary-button:hover { border-color: var(--color-border-strong); }
.ghost-button { padding: 6px 0; border: 0; background: transparent; color: var(--color-primary); font-size: 12px; }

.theme-toggle, .locale-switch { display: inline-flex; align-items: center; }
.locale-switch { border: 1px solid var(--color-border); border-radius: var(--radius-pill); padding: 2px; gap: 2px; background: var(--color-surface-1); }
.locale-switch button { border: 0; background: transparent; padding: 5px 10px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 600; color: var(--color-text-subtle); min-height: 30px; }
.locale-switch button.active { background: var(--color-primary); color: var(--color-on-primary); }

#offlineBanner {
  margin-bottom: 14px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--color-warning-bg);
  color: var(--color-warning);
  font-size: 12px;
  font-weight: 600;
}

.welcome-strip { padding: 12px 16px; margin-top: 4px; border-radius: var(--radius-md); background: var(--color-surface-2); border: 1px solid var(--color-border); color: var(--color-text-subtle); font-size: 12px; }

.metric-grid { margin-top: 16px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.metric-card, .card {
  background: var(--color-surface-1);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}
.metric-card { min-height: 112px; padding: 16px; position: relative; overflow: hidden; }
.metric-card .metric-icon { position: absolute; right: 14px; top: 14px; width: 32px; height: 32px; display: grid; place-items: center; border-radius: var(--radius-sm); background: var(--color-info-bg); color: var(--color-info); font-weight: 700; }
.metric-card small { color: var(--color-text-subtle); font-size: 11px; }
.metric-card strong { display: block; margin-top: 10px; font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
.metric-card p { margin-top: 8px; color: var(--color-text-subtle); font-size: 11px; }
.metric-card p b { color: var(--color-text); }
.metric-card.warning .metric-icon { background: var(--color-warning-bg); color: var(--color-warning); }
.metric-card.blue .metric-icon { background: var(--color-info-bg); color: var(--color-info); }
.metric-card.orange .metric-icon { background: var(--color-status-new-bg); color: var(--color-status-new); }

.dashboard-grid { margin-top: 16px; display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.75fr); gap: 16px; }
.card { padding: 20px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-head h2 { margin-top: 6px; font-size: 16px; }
.soft-badge { padding: 6px 9px; border-radius: var(--radius-sm); background: var(--color-surface-3); color: var(--color-text-muted); font-size: 11px; font-weight: 700; }

.pipeline-chart { min-height: 200px; margin-top: 20px; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 0 6px; border-bottom: 1px solid var(--color-border); }
.pipeline-col { flex: 1; height: 180px; min-width: 44px; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; }
.pipeline-col strong { font-size: 12px; font-weight: 700; }
.pipeline-bar { width: min(36px, 70%); min-height: 6px; border-radius: var(--radius-xs) var(--radius-xs) 0 0; background: var(--color-primary); }
.pipeline-col span { min-height: 30px; color: var(--color-text-subtle); text-align: center; font-size: 10px; line-height: 1.3; }

.compact-list { margin-top: 12px; display: grid; }
.compact-item { min-height: 60px; padding: 10px 0; display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; align-items: center; gap: 10px; border-bottom: 1px solid var(--color-border); cursor: pointer; }
.compact-item:last-child { border: 0; }
.date-tile { height: 38px; border-radius: var(--radius-sm); display: grid; place-items: center; align-content: center; background: var(--color-surface-3); line-height: 1; }
.date-tile strong { font-size: 13px; font-weight: 700; }
.date-tile small { margin-top: 2px; color: var(--color-text-subtle); font-size: 8px; text-transform: uppercase; }
.compact-item.overdue .date-tile { background: var(--color-danger-bg); color: var(--color-danger); }
.compact-item .item-copy { min-width: 0; display: grid; }
.item-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.item-copy small { margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--color-text-subtle); font-size: 10px; }
.initial-avatar { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--color-surface-3); color: var(--color-text); font-size: 9px; font-weight: 700; }
.recent-card { margin-top: 16px; }

.view-intro { margin-bottom: 16px; display: flex; justify-content: space-between; align-items: flex-end; }
.view-intro h2 { margin-top: 6px; font-size: 22px; }
.view-intro p { margin-top: 4px; color: var(--color-text-subtle); font-size: 12px; }
.list-card { padding: 0; overflow: hidden; }
.filter-bar { padding: 14px 16px; display: flex; gap: 8px; border-bottom: 1px solid var(--color-border); }
.filter-bar .wide { flex: 1; min-width: 220px; }

select, .form-grid input, .form-grid textarea {
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-1);
  color: var(--color-text);
  outline: 0;
  width: 100%;
}
select:focus, .form-grid input:focus, .form-grid textarea:focus { border-color: var(--color-primary); box-shadow: var(--focus-ring); }
.form-grid textarea { min-height: 88px; resize: vertical; }

.responsive-table { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 11px 16px; background: var(--color-surface-2); color: var(--color-text-subtle); font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-align: left; white-space: nowrap; }
td { padding: 13px 16px; border-top: 1px solid var(--color-border); font-size: 12px; vertical-align: middle; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--color-surface-2); }
tbody tr.overdue td:first-child { box-shadow: inset 3px 0 0 var(--color-danger); }
.customer-cell { display: grid; }
.customer-cell strong { font-size: 12px; }
.customer-cell small, td small { margin-top: 2px; color: var(--color-text-subtle); font-size: 10px; }
.id-link { color: var(--color-primary); font-weight: 700; font-size: 11px; }

.status, .priority { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; border-radius: var(--radius-sm); font-size: 10px; font-weight: 700; }
.status { padding: 5px 8px; background: var(--color-surface-3); color: var(--color-text-muted); }
.status::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status-new { background: var(--color-status-new-bg); color: var(--color-status-new); }
.status-assigned { background: var(--color-status-assigned-bg); color: var(--color-status-assigned); }
.status-in-progress { background: var(--color-status-in-progress-bg); color: var(--color-status-in-progress); }
.status-quoted { background: var(--color-status-quoted-bg); color: var(--color-status-quoted); }
.status-closed { background: var(--color-status-closed-bg); color: var(--color-status-closed); }
.status-cancelled { background: var(--color-status-cancelled-bg); color: var(--color-status-cancelled); }
.priority { padding: 4px 7px; border: 1px solid var(--color-border); color: var(--color-text-muted); }
.priority::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--color-text-subtle); }
.priority-urgent::before { background: var(--color-priority-urgent); }
.priority-high::before { background: var(--color-priority-high); }
.priority-medium::before { background: var(--color-priority-medium); }
.priority-low::before { background: var(--color-priority-low); }

.row-actions { display: flex; gap: 6px; }
.mini-button { min-height: 30px; padding: 0 10px; border-radius: var(--radius-sm); border: 1px solid var(--color-border); background: var(--color-surface-1); font-size: 10px; font-weight: 600; }
.mini-button.dark { background: var(--color-primary); color: var(--color-on-primary); border-color: var(--color-primary); }
.empty-state { padding: 44px 16px; color: var(--color-text-subtle); text-align: center; }
.empty-state strong { display: block; margin-bottom: 4px; color: var(--color-text); }

.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.board-column { min-height: 400px; padding: 14px; border-radius: var(--radius-md); background: var(--color-surface-2); }
.board-head { margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; }
.board-head h3 { font-size: 12px; }
.board-head span { min-width: 22px; height: 22px; padding: 0 6px; display: grid; place-items: center; background: var(--color-surface-1); border-radius: var(--radius-pill); font-size: 10px; font-weight: 700; }
.task-card { margin-bottom: 8px; padding: 13px; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface-1); }
.task-card .task-top { display: flex; justify-content: space-between; gap: 8px; }
.task-card h3 { margin: 9px 0 4px; font-size: 12px; }
.task-card p { color: var(--color-text-subtle); font-size: 10px; }
.task-foot { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--color-border); display: flex; align-items: center; justify-content: space-between; }
.task-foot time { color: var(--color-text-subtle); font-size: 10px; }

.team-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.team-card { padding: 18px; }
.team-card-head { display: flex; align-items: center; gap: 10px; }
.team-card-head .avatar { width: 40px; height: 40px; }
.team-card-head span:last-child { display: grid; }
.team-card-head small { color: var(--color-text-subtle); }
.workload { margin-top: 16px; }
.workload-line { display: flex; justify-content: space-between; font-size: 11px; }
.workload-track { height: 6px; margin-top: 7px; border-radius: var(--radius-pill); background: var(--color-surface-3); overflow: hidden; }
.workload-track i { height: 100%; display: block; border-radius: inherit; background: var(--color-primary); }
.team-card .row-actions { margin-top: 12px; justify-content: space-between; align-items: center; }

.drawer-backdrop, .modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}
.drawer-backdrop { z-index: 60; }
.modal-backdrop { z-index: 70; }
.drawer-backdrop.open, .modal-backdrop.open { opacity: 1; visibility: visible; }
.detail-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 61;
  width: min(560px, 100vw);
  padding: 22px;
  overflow-y: auto;
  background: var(--color-canvas);
  border-left: 1px solid var(--color-border);
  transform: translateX(102%);
  transition: transform 0.22s ease;
  box-shadow: var(--shadow-panel);
}
.detail-drawer.open { transform: translateX(0); }
.drawer-head, .modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; padding-bottom: 16px; border-bottom: 1px solid var(--color-border); }
.drawer-head h2, .modal-head h2 { margin-top: 6px; font-size: 18px; }
.detail-hero { padding: 18px 0; }
.detail-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.detail-hero h3 { margin-top: 13px; font-size: 18px; }
.detail-hero > p { margin-top: 6px; color: var(--color-text-subtle); }
.detail-meta { margin-top: 16px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.meta-box { padding: 11px; border-radius: var(--radius-sm); background: var(--color-surface-2); }
.meta-box small { color: var(--color-text-subtle); }
.meta-box strong { display: block; margin-top: 4px; font-size: 12px; }
.meta-box.full { grid-column: 1 / -1; }

.progress-steps { display: grid; grid-template-columns: repeat(4, 1fr); margin: 6px 0 20px; }
.progress-step { position: relative; text-align: center; color: var(--color-text-subtle); font-size: 9px; }
.progress-step::before { content: ""; position: absolute; top: 9px; left: 0; right: 0; height: 2px; background: var(--color-border); }
.progress-step:first-child::before { left: 50%; }
.progress-step:last-child::before { right: 50%; }
.progress-step i { position: relative; width: 20px; height: 20px; margin: 0 auto 6px; display: grid; place-items: center; border-radius: 50%; background: var(--color-border-strong); color: var(--color-on-primary); font-style: normal; z-index: 1; }
.progress-step.done { color: var(--color-primary); font-weight: 700; }
.progress-step.done::before, .progress-step.done i { background: var(--color-primary); }

.drawer-section { padding: 16px 0; border-top: 1px solid var(--color-border); }
.drawer-section-head { margin-bottom: 11px; display: flex; justify-content: space-between; align-items: center; }
.drawer-section-head h3 { font-size: 13px; }
.action-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.action-button { min-height: 62px; padding: 9px; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface-1); display: grid; place-items: center; align-content: center; gap: 4px; font-size: 10px; color: var(--color-text); }
.action-button:hover { border-color: var(--color-border-strong); }
.action-button b { font-size: 16px; color: var(--color-primary); font-style: normal; }
.timeline { display: grid; gap: 12px; }
.timeline-item { padding-left: 18px; position: relative; }
.timeline-item::before { content: ""; position: absolute; left: 2px; top: 4px; width: 7px; height: 7px; border: 3px solid var(--color-canvas); border-radius: 50%; background: var(--color-text-subtle); box-shadow: 0 0 0 1px var(--color-border); }
.timeline-item:not(:last-child)::after { content: ""; position: absolute; left: 7px; top: 16px; bottom: -16px; width: 1px; background: var(--color-border); }
.timeline-item strong { font-size: 11px; }
.timeline-item p { margin-top: 3px; color: var(--color-text-subtle); font-size: 10px; }

.history-now { display: inline-flex; align-items: center; gap: 6px; color: var(--color-text-subtle); font-size: 10px; white-space: nowrap; }
.history-now i { width: 7px; height: 7px; border-radius: 50%; background: var(--color-primary); }
.assignment-timeline { margin-top: 18px; display: grid; }
.assignment-entry { position: relative; padding: 0 0 20px 24px; }
.assignment-entry:last-child { padding-bottom: 0; }
.assignment-entry::before { content: ""; position: absolute; left: 3px; top: 5px; width: 9px; height: 9px; border: 3px solid var(--color-canvas); border-radius: 50%; background: var(--color-text-subtle); box-shadow: 0 0 0 1px var(--color-border); }
.assignment-entry.is-current::before { background: var(--color-primary); box-shadow: 0 0 0 1px var(--color-primary), 0 0 0 5px var(--color-info-bg); }
.assignment-entry:not(:last-child)::after { content: ""; position: absolute; left: 8px; top: 18px; bottom: 0; width: 1px; background: var(--color-border); }
.assignment-entry-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.assignment-entry strong { font-size: 12px; }
.assignment-entry time { color: var(--color-text-subtle); font-size: 9px; white-space: nowrap; }
.assignment-entry p { margin-top: 4px; color: var(--color-text-subtle); font-size: 10px; line-height: 1.55; }
.assignment-entry .assignment-route { color: var(--color-text); font-weight: 600; }
.assignment-current-label { display: inline-flex; margin-top: 6px; padding: 4px 7px; border-radius: var(--radius-sm); background: var(--color-success-bg); color: var(--color-success); font-size: 9px; font-weight: 700; }
.drawer-history { padding: 14px; border-radius: var(--radius-md); background: var(--color-surface-2); }
.drawer-history .assignment-entry::before { border-color: var(--color-surface-2); }

.modal-backdrop { display: grid; place-items: center; padding: 16px; }
.modal { width: min(680px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 22px; border-radius: var(--radius-lg); background: var(--color-canvas); border: 1px solid var(--color-border); transform: translateY(8px) scale(0.99); transition: transform 0.18s; box-shadow: var(--shadow-panel); }
.modal-backdrop.open .modal { transform: none; }
.form-grid { padding-top: 18px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.form-grid label { display: grid; gap: 6px; color: var(--color-text-subtle); font-size: 11px; font-weight: 600; }
.form-grid label.full, .form-grid > .full { grid-column: 1 / -1; }
.field-help { color: var(--color-text-subtle); font-size: 11px; margin: 0; }
.field-warning { color: var(--color-danger); font-size: 11px; margin: -4px 0 0; }
.modal-actions { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--color-border); display: flex; justify-content: flex-end; gap: 8px; }

.combobox-list { position: absolute; z-index: 5; margin-top: 4px; width: 100%; max-height: 220px; overflow-y: auto; background: var(--color-canvas); border: 1px solid var(--color-border); border-radius: var(--radius-md); box-shadow: var(--shadow-panel); }
.combobox-option { padding: 8px 11px; font-size: 12px; display: flex; justify-content: space-between; gap: 8px; cursor: pointer; }
.combobox-option small { color: var(--color-text-subtle); }
.combobox-option:hover, .combobox-option.active { background: var(--color-surface-2); }
.combobox-hint { padding: 8px 11px; font-size: 11px; color: var(--color-text-subtle); }
.form-grid label:has(> input[role="combobox"]) { position: relative; }

.login-screen { position: fixed; inset: 0; z-index: 100; display: grid; grid-template-columns: minmax(400px, 0.85fr) 1.15fr; background: var(--color-canvas); }
.login-screen.hidden { display: none; }
.login-screen.restoring .login-panel { opacity: 0.6; pointer-events: none; }
.login-panel { width: min(420px, 100%); margin: auto; padding: 36px; }
.login-brand { margin-bottom: 56px; display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.login-panel h1 { margin-top: 14px; font-size: 34px; line-height: 1.15; }
.login-panel > p { margin-top: 14px; color: var(--color-text-subtle); line-height: 1.7; }
.login-panel form { margin-top: 28px; display: grid; gap: 14px; }
.login-panel label { display: grid; gap: 6px; color: var(--color-text-subtle); font-size: 11px; font-weight: 600; }
.login-panel input { height: 44px; padding: 0 13px; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface-1); color: var(--color-text); outline: 0; }
.login-panel input:focus { border-color: var(--color-primary); box-shadow: var(--focus-ring); }
.login-button { height: 46px; margin-top: 4px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; }
#loginMessage { display: block; min-height: 18px; color: var(--color-danger); font-size: 12px; }
.login-art { margin: 16px; border-radius: var(--radius-lg); overflow: hidden; position: relative; background: var(--color-surface-2); border: 1px solid var(--color-border); }
.login-quote { position: absolute; left: 8%; bottom: 9%; color: var(--color-text); z-index: 1; }
.login-quote span { color: var(--color-primary); font-size: 10px; font-weight: 700; letter-spacing: 0.14em; }
.login-quote h2 { margin-top: 12px; font-size: clamp(22px, 3vw, 38px); line-height: 1.2; font-weight: 700; }

@media (max-width: 820px) {
  .login-screen { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .login-brand { margin-bottom: 40px; }
}

.toast { position: fixed; left: 50%; bottom: 20px; z-index: 120; max-width: min(420px, calc(100vw - 24px)); padding: 11px 16px; border-radius: var(--radius-md); background: var(--color-text); color: var(--color-canvas); opacity: 0; transform: translate(-50%, 12px); pointer-events: none; transition: 0.2s; font-size: 12px; box-shadow: var(--shadow-panel); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--color-danger); color: #fff; }

body.loading { cursor: progress; }
