/* =========================================================
   MAXQUOTA — Stylesheet (v2 — Indigo/Violet design system)
   ใช้ font Sukhumvit Set ที่วางไว้ใน /fonts/sukhumvit
   รองรับ Light / Dark mode ผ่าน [data-theme] บน <html>
   รองรับจอมือถือ/แท็บเล็ตผ่าน sidebar แบบ off-canvas
   ========================================================= */

@font-face { font-family: 'Sukhumvit Set'; src: url('../../fonts/sukhumvit/SukhumvitSet-Text.ttf') format('truetype'); font-weight: 400; font-style: normal; }
@font-face { font-family: 'Sukhumvit Set'; src: url('../../fonts/sukhumvit/SukhumvitSet-Medium.ttf') format('truetype'); font-weight: 500; font-style: normal; }
@font-face { font-family: 'Sukhumvit Set'; src: url('../../fonts/sukhumvit/SukhumvitSet-SemiBold.ttf') format('truetype'); font-weight: 600; font-style: normal; }
@font-face { font-family: 'Sukhumvit Set'; src: url('../../fonts/sukhumvit/SukhumvitSet-Bold.ttf') format('truetype'); font-weight: 700; font-style: normal; }
@font-face { font-family: 'Sukhumvit Set'; src: url('../../fonts/sukhumvit/SukhumvitSet-Light.ttf') format('truetype'); font-weight: 300; font-style: normal; }

:root {
  --bg: #F6F5FC;
  --surface: #FFFFFF;
  --surface-alt: #FBFAFF;
  --border: #E9E6F5;
  --text-primary: #1A1533;
  --text-secondary: #6B6690;
  --text-muted: #9C97BC;

  --primary: #7C3AED;
  --primary-dark: #6423D5;
  --primary-light: #A78BFA;
  --primary-soft: #F1EBFE;

  --topbar-1: #7C3AED;
  --topbar-2: #6D28D9;
  --sidebar-bg: #FFFFFF;
  --sidebar-border: var(--border);
  --sidebar-text: #6B6690;
  --sidebar-text-hover: #1A1533;
  --sidebar-heading: #9C97BC;

  --danger: #F1395A;
  --danger-soft: #FDE7EC;
  --success: #12B981;
  --success-soft: #E3FBF0;
  --warning: #F59E0B;
  --warning-soft: #FFF4E0;
  --purple: #A855F7;
  --purple-soft: #F6EDFF;
  --teal: #06B6D4;
  --teal-soft: #E1F8FC;

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 9px;
  --shadow-card: 0 1px 2px rgba(23,19,49,0.03), 0 10px 26px -16px rgba(23,19,49,0.14);
  --shadow-pop: 0 10px 22px -3px rgba(124,58,237,0.4);
  --shadow-modal: 0 30px 70px -25px rgba(15,10,35,0.45);
}

:root[data-theme="dark"] {
  --bg: #0D0B1C;
  --surface: #171331;
  --surface-alt: #1C1839;
  --border: #2C2757;
  --text-primary: #F3F1FC;
  --text-secondary: #ACA5D2;
  --text-muted: #766EA0;
  --primary-soft: #251E4C;
  --danger-soft: #3B1D29;
  --success-soft: #0F2E29;
  --warning-soft: #33270E;
  --purple-soft: #2A1F4C;
  --teal-soft: #10282F;

  --sidebar-bg: linear-gradient(175deg, #16112E, #241A4D);
  --sidebar-border: transparent;
  --sidebar-text: #A199C9;
  --sidebar-text-hover: #FFFFFF;
  --sidebar-heading: #6C639A;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
body {
  font-family: 'Sukhumvit Set', 'Noto Sans Thai', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { transition: filter .12s ease, background-color .12s ease, border-color .12s ease, transform .12s ease, box-shadow .12s ease; }
input, select, textarea { transition: border-color .12s ease, box-shadow .12s ease; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary) !important; box-shadow: 0 0 0 3px rgba(109,91,242,0.18);
}
table { border-collapse: collapse; width: 100%; }
[hidden] { display: none !important; }
[data-modal-open] { cursor: pointer; }
.bar-col[data-modal-open]:hover .bar { filter: brightness(1.12); }
.chart-legend .item[data-modal-open]:hover { background: var(--bg); border-radius: 8px; margin: 0 -6px; padding: 4px 6px; }
.kpi-card[data-modal-open]:hover { border-color: var(--primary); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--text-muted) 45%, transparent); border-radius: 20px; border: 2px solid var(--bg); }

/* ---------- Layout utilities ---------- */
.split-aside { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.split-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.split-main-side { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; align-items: start; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.stack-col { display: flex; flex-direction: column; gap: 18px; }

/* ---------- Top bar (ม่วงเต็มความกว้าง แบบ Refrens) ---------- */
body { display: flex; flex-direction: column; height: 100vh; overflow-x: hidden; }
.top-bar {
  flex-shrink: 0; height: 56px; background: linear-gradient(100deg, var(--topbar-1), var(--topbar-2));
  display: flex; align-items: center; justify-content: space-between; padding: 0 22px; box-sizing: border-box;
  position: relative; z-index: 60; gap: 12px; min-width: 0;
}
.top-bar-brand { display: flex; align-items: center; gap: 10px; color: #fff; min-width: 0; flex-shrink: 1; overflow: hidden; }
.top-bar-brand .logo { width: 30px; height: 30px; border-radius: 9px; background: rgba(255,255,255,0.18); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.top-bar-brand .name { font-weight: 700; font-size: 14.5px; letter-spacing: .2px; white-space: nowrap; }
.top-bar-icons { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.top-bar-icon { width: 34px; height: 34px; border-radius: 9px; border: none; background: rgba(255,255,255,0.12); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.top-bar-icon:hover { background: rgba(255,255,255,0.22); }
.top-bar-avatar { width: 30px; height: 30px; border-radius: 50%; background: rgba(255,255,255,0.2); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; margin-left: 4px; }

/* ---------- App shell ---------- */
.app-shell { display: flex; flex: 1; min-height: 0; }

.sidebar {
  width: 250px; flex-shrink: 0; background: var(--sidebar-bg); border-right: 1px solid var(--sidebar-border);
  display: flex; flex-direction: column; padding: 18px 12px; box-sizing: border-box;
  position: relative; overflow-y: auto;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px 8px; position: relative; border-bottom: 1px solid var(--sidebar-border); margin-bottom: 12px; }
.sidebar-brand .logo { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(160deg, var(--primary-light), var(--primary-dark)); box-shadow: 0 6px 14px rgba(124,58,237,0.35); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; }
.sidebar-brand .name { color: var(--text-primary); font-weight: 700; font-size: 14px; }
.sidebar-brand .sub { color: var(--text-muted); font-size: 10.5px; }
.sidebar-close { display: none; margin-left: auto; width: 30px; height: 30px; border-radius: 9px; border: none; background: var(--bg); color: var(--text-secondary); align-items: center; justify-content: center; cursor: pointer; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; position: relative; }
.nav-group-label { font-size: 10px; font-weight: 700; color: var(--sidebar-heading); text-transform: uppercase; letter-spacing: .5px; padding: 14px 12px 6px 12px; }
.nav-item {
  display: flex; align-items: center; justify-content: space-between; gap: 11px;
  padding: 9px 12px; border-radius: 10px; color: var(--sidebar-text); font-size: 13.3px; font-weight: 500;
  transition: background-color .15s ease, color .15s ease;
}
.nav-item:hover { background: var(--primary-soft); color: var(--sidebar-text-hover); }
.nav-item .nav-left { display: flex; align-items: center; gap: 11px; }
.nav-item.active { background: var(--primary-soft); color: var(--primary-dark); font-weight: 700; }
:root[data-theme="dark"] .nav-item.active { background: linear-gradient(135deg, var(--primary-light), var(--primary-dark)); color: #fff; box-shadow: 0 8px 18px -4px rgba(124,58,237,0.55); }
:root[data-theme="dark"] .nav-item.active:hover { background: linear-gradient(135deg, var(--primary-light), var(--primary-dark)); }
.nav-item.soon { opacity: .55; cursor: default; }
.nav-item .soon-tag { font-size: 9px; font-weight: 700; background: var(--bg); color: var(--text-muted); padding: 2px 6px; border-radius: 8px; }
.nav-badge { background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 10px; }
.nav-divider { height: 1px; background: var(--sidebar-border); margin: 12px 6px; }
.nav-sub { padding-left: 26px; }

.sidebar-collapse-toggle {
  margin-top: auto; display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; height: 34px; border-radius: 9px; border: 1px solid var(--sidebar-border);
  background: none; color: var(--text-muted); cursor: pointer; flex-shrink: 0; font-size: 11.5px; font-weight: 700;
  margin-bottom: 10px; transition: background-color .15s ease, color .15s ease;
}
.sidebar-collapse-toggle:hover { background: var(--primary-soft); color: var(--primary-dark); }
.sidebar-collapse-toggle svg { transition: transform .2s ease; flex-shrink: 0; }

.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 12px 10px; border-radius: 13px; background: var(--bg); position: relative; }
.sidebar-user:hover { background: var(--primary-soft); }
.avatar { border-radius: 50%; background: linear-gradient(160deg, var(--primary-light), var(--primary-dark)); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; object-fit: cover; }
.sidebar-user .avatar { width: 32px; height: 32px; font-size: 12px; }
.sidebar-user .u-name { color: var(--text-primary); font-size: 12.5px; font-weight: 600; }
.sidebar-user .u-role { color: var(--text-muted); font-size: 10.5px; }

/* ---------- Sidebar collapsed (icon-only) mode ---------- */
.app-shell.sidebar-collapsed .sidebar { width: 76px; padding-left: 10px; padding-right: 10px; }
.app-shell.sidebar-collapsed .sidebar-brand { display: none; }
.app-shell.sidebar-collapsed .nav-group-label { display: none; }
.app-shell.sidebar-collapsed .nav-item { justify-content: center; padding: 10px 8px; }
.app-shell.sidebar-collapsed .nav-item .nav-left { font-size: 0; gap: 0; }
.app-shell.sidebar-collapsed .nav-badge { display: none; }
.app-shell.sidebar-collapsed .nav-sub { padding-left: 0; }
.app-shell.sidebar-collapsed .sidebar-user { justify-content: center; padding: 10px; }
.app-shell.sidebar-collapsed .sidebar-user .u-name,
.app-shell.sidebar-collapsed .sidebar-user .u-role { display: none; }
.app-shell.sidebar-collapsed .sidebar-collapse-toggle span { display: none; }
.app-shell.sidebar-collapsed .sidebar-collapse-toggle svg { transform: rotate(180deg); }
@media (max-width: 960px) {
  .sidebar-collapse-toggle { display: none; }
}

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  height: 60px; flex-shrink: 0; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 30px; justify-content: space-between; box-sizing: border-box; gap: 14px; min-width: 0;
}
.topbar > div { min-width: 0; }
.topbar .crumb { font-size: 12.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .crumb b { color: var(--text-primary); font-weight: 700; }
.search-pill-wrap { position: relative; width: 300px; }
.search-pill { display: flex; align-items: center; gap: 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 9px 16px; width: 100%; color: var(--text-muted); font-size: 13px; box-sizing: border-box; }
.search-pill input { border: none; background: transparent; width: 100%; font-size: 13px; color: var(--text-primary); }
.search-pill input::placeholder { color: var(--text-muted); }
.search-results { position: absolute; top: calc(100% + 8px); left: 0; width: 100%; min-width: 320px; max-height: 420px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-modal); z-index: 250; display: none; }
.search-results.open { display: block; }
.search-results .group-label { padding: 10px 14px 4px; font-size: 10.5px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; }
.search-results .result-item { display: flex; flex-direction: column; gap: 2px; padding: 9px 14px; cursor: pointer; }
.search-results .result-item:hover { background: var(--bg); }
.search-results .result-item .title { font-size: 13px; font-weight: 700; }
.search-results .result-item .sub { font-size: 11.5px; color: var(--text-secondary); }
.search-results .empty, .search-results .hint { padding: 18px 14px; text-align: center; color: var(--text-muted); font-size: 12.5px; }
.content { flex: 1; overflow: auto; padding: 30px 34px; box-sizing: border-box; }

.menu-toggle { display: none; width: 36px; height: 36px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--surface); align-items: center; justify-content: center; cursor: pointer; color: var(--text-secondary); flex-shrink: 0; }
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(10,7,26,0.55); z-index: 90; }

.icon-btn { width: 34px; height: 34px; border-radius: 9px; border: 1.5px solid var(--border); background: var(--surface); display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-secondary); }
.icon-btn:hover { background: var(--bg); color: var(--text-primary); }
.theme-toggle { display: flex; align-items: center; gap: 7px; border: 1px solid var(--border); background: var(--bg); border-radius: 22px; padding: 7px 14px 7px 7px; cursor: pointer; color: var(--text-secondary); font-weight: 700; font-size: 12px; }
.theme-toggle .dot { width: 22px; height: 22px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px rgba(15,23,42,0.15); display: flex; align-items: center; justify-content: center; }

/* ---------- Cards / typography ---------- */
.page-title { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; margin: 0 0 4px 0; }
.page-sub { font-size: 13.5px; color: var(--text-secondary); margin: 0 0 22px 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); transition: box-shadow .15s ease, transform .15s ease; }
.card-pad { padding: 22px; }
.card-title { font-size: 14.5px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; gap: 10px; }
.icon-badge { width: 30px; height: 30px; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 18px; margin-bottom: 26px; }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px 22px; box-shadow: var(--shadow-card); transition: transform .15s ease, box-shadow .15s ease; }
.kpi-card:hover { transform: translateY(-3px); box-shadow: 0 16px 32px -18px rgba(23,19,49,0.24); }
.kpi-icon { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; margin-bottom: 16px; }
.kpi-label { font-size: 12.5px; color: var(--text-secondary); font-weight: 600; margin-bottom: 6px; }
.kpi-value { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 11px 20px; border-radius: 11px; font-weight: 700; font-size: 13.5px; cursor: pointer; border: 1.5px solid transparent; white-space: nowrap; }
.btn-primary { background: linear-gradient(135deg, var(--primary-light), var(--primary-dark)); color: #fff; box-shadow: var(--shadow-pop); border: none; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-secondary { background: var(--surface); color: var(--text-primary); border: 1.5px solid var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-secondary.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-danger { background: var(--danger-soft); color: #C0243F; border: 1.5px solid transparent; }
.btn-danger:hover { filter: brightness(0.97); }
.btn-success { background: var(--success); color: #fff; border: none; box-shadow: 0 10px 20px -6px rgba(18,185,129,0.45); }
.btn-success:hover { filter: brightness(1.05); }
.btn-sm { padding: 8px 14px; font-size: 12.5px; border-radius: 9px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Dropdown menu (row actions) ---------- */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 175px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-modal); z-index: 220; display: none; overflow: hidden; padding: 5px; }
.dropdown-menu.open { display: block; }
.dropdown-menu a, .dropdown-menu button { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; font-size: 12.5px; text-align: left; background: none; border: none; border-radius: 8px; cursor: pointer; color: var(--text-primary); box-sizing: border-box; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--bg); }
.dropdown-menu button.danger, .dropdown-menu a.danger { color: var(--danger); }
.dropdown-menu button.danger:hover, .dropdown-menu a.danger:hover { background: var(--danger-soft); }
.dropdown-menu form { margin: 0; }

/* ---------- Row / icon actions ---------- */
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.icon-action { width: 30px; height: 30px; border-radius: 8px; border: 1.5px solid var(--border); background: var(--surface); display: inline-flex; align-items: center; justify-content: center; color: var(--text-secondary); cursor: pointer; flex-shrink: 0; }
.icon-action:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--primary-soft); }
.icon-action.danger:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-soft); }

/* ---------- Forms ---------- */
.form-label { display: block; font-size: 12px; font-weight: 700; color: var(--text-secondary); margin-bottom: 7px; }
.form-control { width: 100%; box-sizing: border-box; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 10px; font-size: 13px; background: var(--surface); color: var(--text-primary); }
textarea.form-control { resize: vertical; }
.form-row { display: grid; gap: 14px; }
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 6px; }
.form-error { font-size: 11.5px; color: var(--danger); margin-top: 6px; }
.form-group { margin-bottom: 14px; }

/* ---------- Table ---------- */
.data-table { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-card); }
.data-table table { width: 100%; }
.data-table th { text-align: left; font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; padding: 13px 22px; background: var(--surface-alt); border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: 15px 22px; border-top: 1px solid var(--border); font-size: 13px; }
.data-table tbody tr { transition: background-color .12s ease; }
.data-table tbody tr:hover { background: color-mix(in srgb, var(--surface) 96%, var(--primary) 4%); }
.data-table th.sortable a { display: inline-flex; align-items: center; gap: 4px; color: inherit; cursor: pointer; }
.data-table th.sortable a:hover { color: var(--text-primary); }
.data-table th.sortable .arrow { font-size: 9px; opacity: .55; }
.data-table th.sortable a.active .arrow { opacity: 1; color: var(--primary); }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-right { text-align: right; }
.fw-700 { font-weight: 700; }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.page-link { min-width: 32px; height: 32px; padding: 0 6px; display: flex; align-items: center; justify-content: center; border-radius: 8px; font-size: 12.5px; font-weight: 700; color: var(--text-secondary); }
.page-link:hover { background: var(--bg); }
.page-link.active { background: linear-gradient(135deg, var(--primary-light), var(--primary-dark)); color: #fff; }
.page-link.disabled { opacity: .35; pointer-events: none; }

/* ---------- Empty state ---------- */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 48px 24px; color: var(--text-muted); text-align: center; }
.empty-state .icon-badge { width: 52px; height: 52px; border-radius: 16px; background: var(--primary-soft); color: var(--primary); }

/* ---------- Items table (quotation form) ---------- */
.items-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.items-table { width: 100%; border-collapse: collapse; min-width: 720px; }
.items-table th { text-align: left; font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; padding: 0 4px 10px 4px; border-bottom: 1px solid var(--border); }
.items-table td { padding: 8px 4px; border-bottom: 1px solid var(--border); vertical-align: top; }
.items-table input, .items-table select { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 8px 9px; font-size: 12.5px; background: var(--surface); color: var(--text-primary); }
.items-table textarea { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 8px 9px; font-size: 12.5px; background: var(--surface); color: var(--text-primary); resize: vertical; min-height: 38px; font-family: inherit; }
.items-table .col-desc { min-width: 220px; }
.items-table .col-num { width: 90px; }
.items-table .col-total { width: 110px; text-align: right; font-weight: 700; padding-top: 16px; }
.row-remove { width: 26px; height: 26px; border-radius: 7px; border: none; background: var(--danger-soft); color: var(--danger); cursor: pointer; font-weight: 700; }

/* ---------- Dropzone / attachments ---------- */
.dropzone { border: 1.5px dashed color-mix(in srgb, var(--text-muted) 55%, transparent); border-radius: 14px; padding: 28px; display: flex; flex-direction: column; align-items: center; gap: 10px; background: var(--surface-alt); margin-bottom: 16px; text-align: center; transition: border-color .15s, background .15s; cursor: pointer; }
.dropzone.drag-over { border-color: var(--primary); background: var(--primary-soft); }
.attach-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.attach-thumb { width: 96px; }
.attach-thumb .pic { width: 96px; height: 74px; border-radius: 10px; background: var(--primary-soft); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; margin-bottom: 6px; overflow: hidden; position: relative; }
.attach-thumb .pic img { width: 100%; height: 100%; object-fit: cover; }
.attach-thumb .name { font-size: 10px; color: var(--text-secondary); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach-remove { position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; border-radius: 50%; background: rgba(15,10,35,0.65); color: #fff; border: none; font-size: 11px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.attach-edit { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: rgba(15,10,35,0.65); color: #fff; border: none; font-size: 9px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.attach-edit:hover, .attach-remove:hover { background: var(--primary); }

/* ---------- Charts (dashboard) ---------- */
.donut { --hole: 62%; width: var(--dsize, 150px); height: var(--dsize, 150px); border-radius: 50%; position: relative; flex-shrink: 0; }
.donut::before { content: ''; position: absolute; inset: 0; border-radius: 50%; background: inherit; }
.donut-hole { position: absolute; inset: 19%; border-radius: 50%; background: var(--surface); display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: inset 0 1px 3px rgba(23,19,49,0.06); }
.donut-value { font-size: 20px; font-weight: 700; line-height: 1.1; }
.donut-label { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.chart-legend { display: flex; flex-direction: column; gap: 10px; }
.chart-legend .item { display: flex; align-items: center; gap: 9px; font-size: 12.5px; }
.chart-legend .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.chart-legend .lbl { flex: 1; color: var(--text-secondary); }
.chart-legend .val { font-weight: 700; }

.bar-chart { display: flex; align-items: flex-end; gap: 14px; height: 150px; padding-top: 22px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; }
.bar-track { width: 100%; height: 120px; display: flex; align-items: flex-end; position: relative; }
.bar-track .bar { width: 100%; border-radius: 7px 7px 3px 3px; background: linear-gradient(180deg, var(--primary-light), var(--primary-dark)); min-height: 4px; position: relative; }
.bar-track .bar .val { position: absolute; top: -19px; left: 0; right: 0; text-align: center; font-size: 10.5px; font-weight: 700; color: var(--text-secondary); white-space: nowrap; }
.bar-col .lbl { font-size: 10.5px; color: var(--text-muted); text-align: center; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10,7,26,0.55); display: flex; align-items: center; justify-content: center; z-index: 300; opacity: 0; pointer-events: none; transition: opacity .15s ease; padding: 20px; }
.modal-backdrop.open { opacity: 1; pointer-events: auto; }
.modal { background: var(--surface); border-radius: var(--radius-lg); width: 100%; max-width: 460px; box-shadow: var(--shadow-modal); transform: translateY(12px) scale(.98); transition: transform .15s ease; max-height: 90vh; overflow-y: auto; }
.modal-backdrop.open .modal { transform: translateY(0) scale(1); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 15px; font-weight: 700; }
.modal-close { width: 28px; height: 28px; border-radius: 8px; border: none; background: var(--bg); color: var(--text-secondary); cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.modal-close:hover { background: var(--border); }
.modal-body { padding: 22px; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 22px; border-top: 1px solid var(--border); }
.modal-icon { width: 48px; height: 48px; border-radius: 14px; display: flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.modal-icon.danger { background: var(--danger-soft); color: var(--danger); }
.modal-icon.info { background: var(--primary-soft); color: var(--primary); }
.modal-icon.success { background: var(--success-soft); color: var(--success); }
.modal-icon.warning { background: var(--warning-soft); color: #D97706; }

/* ---------- Approval master-detail ---------- */
.approval-shell { display: flex; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; background: var(--surface); box-shadow: var(--shadow-card); }
.approval-list { width: 360px; flex-shrink: 0; border-right: 1px solid var(--border); max-height: 720px; overflow: auto; }
.approval-detail { flex: 1; padding: 28px 32px; min-width: 0; }
@media (max-width: 960px) {
  .approval-shell { flex-direction: column; }
  .approval-list { width: 100%; border-right: none; border-bottom: 1px solid var(--border); max-height: 280px; }
  .approval-detail { padding: 20px; }
}

/* ---------- Status pills already inline via PHP (status_badge) ---------- */

/* ---------- Login ---------- */
.auth-shell { min-height: 100vh; display: flex; background: var(--surface); }
.auth-brand { width: 480px; flex-shrink: 0; background: linear-gradient(175deg, #4F46E5, #4338CA); box-sizing: border-box; padding: 52px 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; color: #fff; }
.auth-form-wrap { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; padding: 40px; box-sizing: border-box; overflow-x: hidden; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card.wide { max-width: 620px; }
.tab-toggle { display: flex; gap: 4px; background: var(--bg); border-radius: 12px; padding: 4px; margin-bottom: 30px; }
.tab-toggle a { flex: 1; text-align: center; padding: 10px 0; border-radius: 9px; font-size: 14px; font-weight: 700; color: var(--text-secondary); }
.tab-toggle a.active { background: var(--surface); color: var(--text-primary); box-shadow: 0 1px 4px rgba(15,23,42,0.1); }

/* ---------- Alerts / flash ---------- */
.alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: 10px; font-size: 12.5px; line-height: 1.6; margin-bottom: 16px; }
.alert-success { background: var(--success-soft); color: #0E8F63; }
.alert-error { background: var(--danger-soft); color: #C0243F; }
.alert-info { background: var(--primary-soft); color: var(--primary-dark); }
.alert-warning { background: var(--warning-soft); color: #92650E; }

/* ---------- Print (quotation view) ---------- */
@media print {
  .no-print { display: none !important; }
  .sidebar, .topbar, .sidebar-backdrop, .top-bar { display: none !important; }
  .content { padding: 0 !important; overflow: visible !important; }
  body { background: #fff !important; }
  .doc-page { box-shadow: none !important; margin: 0 !important; page-break-after: always; }
  .doc-page:last-child { page-break-after: auto; }
}
.doc-page { width: 794px; min-height: 1050px; background: #fff; box-shadow: 0 24px 50px -22px rgba(15,23,42,0.4), 0 2px 10px rgba(15,23,42,0.08); border-radius: 4px; box-sizing: border-box; padding: 64px; position: relative; margin: 0 auto 24px auto; color: #0F172A; display: flex; flex-direction: column; }
.doc-footer-block { margin-top: auto; padding-top: 36px; }
.doc-scroll { background: #E4E7ED; padding: 36px 0 60px 0; }
:root[data-theme="dark"] .doc-scroll { background: #05070D; }
.placed-image { position: absolute; border: 2px solid transparent; border-radius: 10px; cursor: move; }
.placed-image img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; display: block; }
.placed-image .grip, .placed-image .resize-handle { display: none; }
.placed-image.selected { border: 2px dashed var(--primary); background: var(--primary-soft); box-shadow: 0 10px 22px rgba(109,91,242,0.25); }
.placed-image.selected .grip { position: absolute; top: -11px; left: 50%; transform: translateX(-50%); background: var(--primary); color: #fff; width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: grab; }
.placed-image.selected .resize-handle { position: absolute; right: -6px; bottom: -6px; width: 16px; height: 16px; border-radius: 4px; background: var(--primary); border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); display: block; cursor: nwse-resize; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 960px) {
  .menu-toggle { display: flex; }
  .search-pill-wrap { display: none; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 100;
    transform: translateX(-105%); transition: transform .25s ease;
  }
  .sidebar-close { display: flex; }
  .app-shell.sidebar-open .sidebar { transform: translateX(0); }
  .app-shell.sidebar-open .sidebar-backdrop { display: block; }
  .topbar { padding: 0 18px; }
  .content { padding: 20px; }
  .split-aside, .split-2, .split-main-side { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .page-title { font-size: 19px; }
  .doc-page { width: 100%; padding: 26px; }
  .modal { max-width: 100%; }
  .form-row { grid-template-columns: 1fr !important; }
  .top-bar { padding: 0 12px; }
  .theme-toggle span[data-theme-label] { display: none; }
  .theme-toggle { padding: 7px; gap: 0; }
}

@media (max-width: 420px) {
  .top-bar-brand .name { display: none; }
}

@media (max-width: 860px) {
  .auth-brand { display: none; }
  .auth-form-wrap { padding: 28px 20px; }
}

/* =========================================================
   Automatch-style (indigo/slate, Tailwind-like) — scoped only
   to auth (login/register) card content and the profile page,
   per reference: C:\MAMP\htdocs\automachx (read-only reference)
   ========================================================= */
.io-scope { --io-indigo: #4F46E5; --io-indigo-dark: #4338CA; --io-indigo-100: #E0E7FF; --io-indigo-50: rgba(79,70,229,0.06); --io-slate-50: #F8FAFC; --io-slate-100: #F1F5F9; --io-slate-300: #CBD5E1; --io-slate-400: #94A3B8; --io-slate-500: #64748B; --io-slate-800: #1E293B; }
.io-scope .io-band { background: var(--io-indigo); color: #fff; border-radius: 16px 16px 0 0; padding: 22px 24px; text-align: center; margin: -1px -1px 20px -1px; }
.io-scope .io-band .io-band-icon { font-size: 34px; margin-bottom: 8px; opacity: .95; }
.io-scope .io-band .io-band-title { font-size: 19px; font-weight: 800; letter-spacing: .3px; }
.io-scope h2.io-heading { font-size: 19px; font-weight: 800; color: var(--io-slate-800); margin: 0 0 4px 0; }
.io-scope .io-sub { font-size: 12.5px; color: var(--io-slate-500); font-weight: 500; margin: 0 0 18px 0; }
.io-scope .io-card { background: var(--io-slate-50); border: 1px solid var(--io-slate-100); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.io-scope .io-card-tint { background: var(--io-indigo-50); border: 1px solid rgba(79,70,229,0.14); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.io-scope .io-card-title { font-size: 10px; font-weight: 800; color: var(--io-indigo); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 10px; }
.io-scope label.io-label { display: block; font-size: 10px; font-weight: 800; color: var(--io-slate-500); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.io-scope .io-input, .io-scope select.io-input, .io-scope textarea.io-input {
  width: 100%; box-sizing: border-box; padding: 10px 13px; border: 1px solid var(--io-slate-300); border-radius: 11px;
  font-size: 13.5px; background: #fff; color: var(--io-slate-800); transition: all .15s ease;
}
.io-scope .io-input:focus { outline: none; border-color: var(--io-indigo) !important; box-shadow: 0 0 0 3px rgba(79,70,229,0.18); background: #fff; }
.io-scope .io-input-wrap { position: relative; }
.io-scope .io-input-wrap .io-icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--io-slate-400); font-size: 13px; pointer-events: none; }
.io-scope .io-input-wrap .io-input { padding-left: 36px; }
.io-scope .io-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; background: var(--io-indigo); color: #fff; font-weight: 800; font-size: 14px; padding: 13px; border: none; border-radius: 12px; cursor: pointer; box-shadow: 0 10px 20px -8px rgba(79,70,229,0.55); transition: all .12s ease; }
.io-scope .io-btn:hover { background: var(--io-indigo-dark); }
.io-scope .io-btn:active { transform: scale(.98); }
.io-scope .io-btn-outline { background: #fff; color: var(--io-slate-500); border: 1.5px solid var(--io-slate-300); box-shadow: none; }
.io-scope .io-btn-outline:hover { background: var(--io-slate-50); }
.io-scope .io-foot { text-align: center; padding-top: 14px; margin-top: 6px; border-top: 1px solid var(--io-slate-100); font-size: 12.5px; color: var(--io-slate-500); }
.io-scope .io-foot a, .io-scope .io-foot button.io-link { color: var(--io-indigo); font-weight: 800; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; background: none; border: none; cursor: pointer; font-size: inherit; padding: 0; }
.io-scope .io-avatar-upload { width: 68px; height: 68px; border-radius: 50%; background: #fff; border: 2px solid var(--io-indigo-100); display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; flex-shrink: 0; color: var(--io-indigo-100); font-size: 22px; }
.io-scope .io-avatar-upload img { width: 100%; height: 100%; object-fit: cover; }
.io-scope .io-toggle-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.io-scope .io-toggle-2 a, .io-scope .io-toggle-2 button { padding: 10px 12px; border-radius: 10px; font-size: 13px; font-weight: 800; border: 1.5px solid var(--io-slate-300); background: #fff; color: var(--io-slate-500); text-align: center; cursor: pointer; }
.io-scope .io-toggle-2 a.active, .io-scope .io-toggle-2 button.active { background: var(--io-indigo); color: #fff; border-color: var(--io-indigo); box-shadow: 0 4px 10px -3px rgba(79,70,229,.5); }
.io-scope .io-grid-3 { display: grid; grid-template-columns: 96px 1fr 1fr; gap: 10px; }
.io-scope .io-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 560px) {
  .io-scope .io-grid-3 { grid-template-columns: 1fr; }
  .io-scope .io-grid-2 { grid-template-columns: 1fr; }
}
.io-scope .io-switch-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.io-scope .io-switch { position: relative; display: inline-block; width: 40px; height: 23px; flex-shrink: 0; }
.io-scope .io-switch input { opacity: 0; width: 0; height: 0; }
.io-scope .io-switch .io-slider { position: absolute; cursor: pointer; inset: 0; background: #CBD5E1; border-radius: 24px; transition: background-color .15s ease; }
.io-scope .io-switch .io-slider:before { content: ''; position: absolute; width: 17px; height: 17px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .15s ease; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.io-scope .io-switch input:checked + .io-slider { background: #10B981; }
.io-scope .io-switch input:checked + .io-slider:before { transform: translateX(17px); }
.io-scope .io-switch.io-switch-teal input:checked + .io-slider { background: #06B6D4; }
.io-scope details.io-card summary { list-style: none; }
.io-scope details.io-card summary::-webkit-details-marker { display: none; }
.io-scope details.io-card[open] summary { margin-bottom: 4px; }
