@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Playfair+Display:wght@600;700&display=swap');

:root {
  --ochre: #ab7b2d;
  --ochre-dark: #855d19;
  --ochre-pale: #f3e9d8;
  --sand: #faf8f5;
  --page-edge: #efe9e1;
  --ink: #231e1a;
  --deep: #231e1a;
  --ink-soft: #6f6861;
  --paper: #ffffff;
  --surface-muted: #f7f3ee;
  --line: #e6dfd7;
  --line-soft: #f0ebe4;
  --table-hover: #fffdf9;
  --topbar-bg: rgba(255,255,255,.9);
  --bottom-nav-bg: rgba(255,255,255,.96);
  --sidebar-bg: #231e1a;
  --green: #2f9e6e;
  --green-bg: #eef3ee;
  --green-line: #d6e7dc;
  --red: #c0392b;
  --red-bg: #fdf0ef;
  --red-line: #f2d6d3;
  --switch-bg: #d8d0c7;
  --shadow: 0 18px 45px rgba(35, 30, 26, .08);
}

[data-theme="dark"] {
  --ochre: #d19a3d;
  --ochre-dark: #f0bb62;
  --ochre-pale: #3a2d19;
  --sand: #171412;
  --page-edge: #0e0d0c;
  --ink: #f5efe7;
  --deep: #0d0c0b;
  --ink-soft: #b8aea3;
  --paper: #211e1a;
  --surface-muted: #2b2621;
  --line: #40372f;
  --line-soft: #332c26;
  --table-hover: #2a251f;
  --topbar-bg: rgba(33,30,26,.92);
  --bottom-nav-bg: rgba(33,30,26,.97);
  --sidebar-bg: #0e0d0c;
  --green: #5bd191;
  --green-bg: #1c3428;
  --green-line: #2d5a42;
  --red: #ff8278;
  --red-bg: #3c211f;
  --red-line: #6a3935;
  --switch-bg: #5b5148;
  --shadow: 0 18px 45px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--page-edge); }
body { margin: 0; min-width: 320px; background: var(--sand); color: var(--ink); font-family: "DM Sans", system-ui, sans-serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.icon { width: 1em; height: 1em; flex: 0 0 auto; display: inline-block; vertical-align: -0.14em; stroke: currentColor; }
.icon-button { gap: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.brand-serif { font-family: "Playfair Display", Georgia, serif; }
.muted { color: var(--ink-soft); }
.small { font-size: .8rem; }
.tiny { font-size: .7rem; }
.mono { font-variant-numeric: tabular-nums; }
.eyebrow { color: var(--ochre-dark); font-size: .7rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }

.login-page { min-height: 100vh; position: relative; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 10% 0%, #fff 0, var(--sand) 40%, var(--page-edge) 100%); }
.login-tools { position: absolute; top: 20px; right: 20px; display: flex; align-items: center; gap: 8px; }
.login-card { width: min(460px, 100%); background: var(--paper); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); padding: 34px; }
.brand-mark { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 15px; background: var(--deep); color: #f4d9a8; font-size: 1.4rem; }
.brand-mark .icon { width: 1.15em; height: 1.15em; }
.login-heading { margin: 24px 0 8px; font: 700 2rem/1.1 "Playfair Display", Georgia, serif; }
.login-copy { margin: 0 0 24px; color: var(--ink-soft); line-height: 1.55; }
.demo-logins { margin-top: 24px; padding: 13px 14px; border-radius: 14px; background: var(--ochre-pale); color: var(--ochre-dark); font-size: .78rem; line-height: 1.6; }
.demo-logins code { color: var(--ink); }

.app-shell { min-height: 100vh; display: flex; }
.sidebar { width: 248px; flex: 0 0 248px; display: flex; flex-direction: column; background: var(--sidebar-bg); color: #fff; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 22px 20px; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-brand .brand-mark { width: 32px; height: 32px; border-radius: 10px; background: var(--ochre); color: var(--deep); font-size: .9rem; }
.sidebar-brand span:last-child { font: 700 1.05rem "Playfair Display", Georgia, serif; }
.sidebar-label { padding: 22px 20px 8px; color: rgba(255,255,255,.4); font-size: .65rem; letter-spacing: .16em; text-transform: uppercase; }
.nav-list { display: grid; gap: 3px; padding: 0 10px; }
.nav-link { display: flex; align-items: center; gap: 11px; border-radius: 10px; padding: 11px 12px; color: rgba(255,255,255,.68); font-size: .83rem; transition: background .2s, color .2s; }
.nav-link:hover, .nav-link.active { background: var(--ochre); color: var(--deep); font-weight: 700; }
.nav-icon { width: 18px; text-align: center; font-size: .95rem; }
.sidebar-footer { margin-top: auto; padding: 16px; border-top: 1px solid rgba(255,255,255,.1); color: rgba(255,255,255,.55); font-size: .72rem; }

.main-area { min-width: 0; flex: 1; background: var(--sand); }
.topbar { height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 32px; background: var(--topbar-bg); border-bottom: 1px solid var(--line); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 10; }
.topbar-title { min-width: 0; }
.topbar-title h1 { margin: 2px 0 0; font: 700 1.35rem "Playfair Display", Georgia, serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.language-control { display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink-soft); }
.language-picker { min-height: 34px; border: 0; outline: 0; background: transparent; color: var(--ink); cursor: pointer; font-size: .78rem; font-weight: 700; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; background: var(--deep); color: #fff; font-size: .72rem; font-weight: 700; }
.user-chip { display: flex; align-items: center; gap: 9px; padding-left: 10px; border-left: 1px solid var(--line); }
.user-chip strong { display: block; font-size: .78rem; }
.user-chip span { display: block; color: var(--ink-soft); font-size: .68rem; }
.mobile-menu { display: none; }
.page { max-width: 1400px; margin: 0 auto; padding: 30px 32px 60px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-heading h2 { margin: 4px 0 0; font: 700 2rem/1.15 "Playfair Display", Georgia, serif; }
.page-heading p { max-width: 700px; margin: 8px 0 0; color: var(--ink-soft); font-size: .9rem; line-height: 1.5; }
.heading-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.btn { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 14px; border: 1px solid transparent; border-radius: 10px; font-size: .8rem; font-weight: 700; transition: transform .15s, box-shadow .15s, background .15s; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--ochre); color: #fff; box-shadow: 0 8px 18px rgba(171,123,45,.22); }
.btn-primary:hover { background: var(--ochre-dark); }
[data-theme="dark"] .btn-primary { color: var(--deep); }
.btn-dark { background: var(--deep); color: #fff; }
.btn-light { background: var(--paper); border-color: var(--line); color: var(--ink); }
.btn-danger { background: var(--red); color: #fff; }
.btn-success { background: var(--green); color: #fff; }
.btn-ghost { min-height: 32px; padding: 6px 9px; background: transparent; color: var(--ink-soft); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin-bottom: 18px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 6px 20px rgba(35,30,26,.025); }
.card-pad { padding: 18px; }
.kpi { position: relative; overflow: hidden; }
.kpi::after { content: ""; position: absolute; width: 90px; height: 90px; right: -30px; bottom: -35px; border-radius: 50%; background: var(--ochre-pale); }
.kpi-label { color: var(--ink-soft); font-size: .72rem; font-weight: 600; }
.kpi-value { margin-top: 7px; font-size: 1.75rem; font-weight: 700; letter-spacing: -.04em; }
.kpi-foot { margin-top: 6px; color: var(--green); font-size: .72rem; font-weight: 600; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-title h3 { margin: 0; font-size: .95rem; }
.section-title a { color: var(--ochre-dark); font-size: .76rem; font-weight: 700; }

.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 680px; border-collapse: collapse; font-size: .8rem; }
th { padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--ink-soft); font-size: .65rem; letter-spacing: .09em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 13px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--table-hover); }
.person-cell { display: flex; align-items: center; gap: 9px; min-width: 170px; }
.person-cell strong { display: block; font-size: .8rem; }
.person-cell span { display: block; margin-top: 2px; color: var(--ink-soft); font-size: .7rem; }
.status, .tag { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 999px; font-size: .68rem; font-weight: 700; white-space: nowrap; }
.status-green { background: var(--green-bg); border: 1px solid var(--green-line); color: var(--green); }
.status-amber { background: var(--ochre-pale); border: 1px solid #e6d3ac; color: var(--ochre-dark); }
.status-red { background: var(--red-bg); border: 1px solid var(--red-line); color: var(--red); }
.status-gray { background: var(--surface-muted); border: 1px solid var(--line); color: var(--ink-soft); }
.list { display: grid; gap: 9px; }
.list-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.list-item-main { min-width: 0; }
.list-item-main strong { display: block; font-size: .82rem; }
.list-item-main span { display: block; margin-top: 4px; color: var(--ink-soft); font-size: .72rem; }
.list-item-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.notice { padding: 13px 15px; border: 1px solid #e6d3ac; border-radius: 12px; background: var(--ochre-pale); color: var(--ochre-dark); font-size: .78rem; line-height: 1.45; }
.notice strong { color: var(--ink); }
.empty { padding: 34px 20px; text-align: center; color: var(--ink-soft); font-size: .82rem; }
.divider { height: 1px; background: var(--line); margin: 18px 0; }

.mobile-dashboard { max-width: 760px; margin: 0 auto; }
.hero-card { padding: 20px; border-radius: 18px; background: var(--deep); color: #fff; }
.hero-card .muted { color: rgba(255,255,255,.62); }
.next-job { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 14px; margin-top: 18px; padding: 16px; border-radius: 14px; background: var(--paper); color: var(--ink); }
.next-job h3 { margin: 0 0 6px; font-size: 1.05rem; }
.next-job p { margin: 4px 0; color: var(--ink-soft); font-size: .78rem; }
.timer-card { padding: 18px; border-radius: 16px; background: linear-gradient(145deg, #302a25, #171412); color: #fff; }
.timer-value { margin: 8px 0; font-size: 2.8rem; font-weight: 700; letter-spacing: .04em; }
.assignment-card { padding: 16px; border: 1px solid var(--line); border-radius: 15px; background: var(--paper); }
.assignment-card.active { border-color: var(--ochre); box-shadow: 0 10px 25px rgba(171,123,45,.1); }
.assignment-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.assignment-card h3 { margin: 0; font-size: .95rem; }
.assignment-meta { display: grid; gap: 5px; margin-top: 10px; color: var(--ink-soft); font-size: .76rem; }
.assignment-actions { display: flex; gap: 8px; margin-top: 14px; }
.assignment-actions .btn { flex: 1; }
.bottom-nav { display: none; }

.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-bar > * { flex: 0 0 auto; }
.search { min-width: 220px; flex: 1 1 240px; }
.field { display: grid; gap: 6px; }
.field label { color: var(--ink-soft); font-size: .72rem; font-weight: 600; }
.compact-select { width: auto; min-width: 135px; }
.input, .select, .textarea { width: 100%; min-height: 40px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; outline: none; background: var(--paper); color: var(--ink); font-size: .82rem; }
.textarea { min-height: 88px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--ochre); box-shadow: 0 0 0 3px rgba(171,123,45,.12); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 13px 0; border-bottom: 1px solid var(--line-soft); font-size: .82rem; }
.switch-row:last-child { border-bottom: 0; }
.switch { position: relative; width: 38px; height: 22px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--switch-bg); transition: .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + span { background: var(--ochre); }
.switch input:checked + span::after { transform: translateX(16px); }

.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(35,30,26,.54); }
.mobile-drawer-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(35,30,26,.54); }
.mobile-drawer { width: min(300px, 88vw); min-height: 100%; padding-bottom: 22px; background: var(--sidebar-bg); color: #fff; box-shadow: 15px 0 35px rgba(0,0,0,.2); }
.mobile-drawer .sidebar-brand { padding: 18px 16px; }
.drawer-close { margin: 24px 16px 0; width: calc(100% - 32px); }
.modal { width: min(620px, 100%); max-height: min(760px, calc(100vh - 40px)); overflow: auto; border-radius: 18px; background: var(--paper); box-shadow: 0 30px 80px rgba(0,0,0,.25); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 19px 21px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font: 700 1.25rem "Playfair Display", Georgia, serif; }
.modal-body { padding: 21px; }
.close { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 9px; background: var(--surface-muted); color: var(--ink-soft); }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 80; max-width: min(380px, calc(100vw - 40px)); padding: 13px 16px; border-radius: 11px; background: var(--ink); color: #fff; box-shadow: 0 15px 40px rgba(35,30,26,.25); font-size: .8rem; }
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
.hidden { display: none !important; }

@media (max-width: 1080px) {
  .sidebar { width: 218px; flex-basis: 218px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  .topbar { height: 62px; padding: 0 16px; }
  .mobile-menu { display: inline-flex; }
  .user-chip { border-left: 0; padding-left: 0; }
  .user-chip > div { display: none; }
  .page { padding: 22px 16px 86px; }
  .page-heading { display: block; margin-bottom: 18px; }
  .page-heading h2 { font-size: 1.65rem; }
  .heading-actions { justify-content: flex-start; margin-top: 14px; }
  .kpi-grid { gap: 10px; }
  .kpi { padding: 14px; }
  .kpi-value { font-size: 1.4rem; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .mobile-dashboard .hero-card { border-radius: 15px; padding: 16px; }
  .next-job { grid-template-columns: 1fr; }
  .next-job .btn { width: 100%; }
  .bottom-nav { position: fixed; right: 0; bottom: 0; left: 0; z-index: 20; display: grid; grid-template-columns: repeat(4, 1fr); padding: 7px 5px max(7px, env(safe-area-inset-bottom)); background: var(--bottom-nav-bg); border-top: 1px solid var(--line); box-shadow: 0 -7px 22px rgba(35,30,26,.08); }
  .bottom-nav button { display: grid; justify-items: center; gap: 3px; border: 0; background: transparent; color: var(--ink-soft); font-size: .64rem; }
  .bottom-nav button.active { color: var(--ochre-dark); font-weight: 700; }
  .bottom-nav .icon { width: 1.05rem; height: 1.05rem; }
  .login-card { padding: 26px 20px; }
}
@media (max-width: 460px) {
  .topbar-title h1 { font-size: 1.1rem; }
  .topbar-title .eyebrow { font-size: .58rem; }
  .topbar-actions .btn { min-width: 34px; padding: 6px; }
  .topbar-actions .btn span { display: none; }
  .language-control { padding: 0 6px; gap: 3px; }
  .language-control .language-picker { max-width: 42px; padding: 0; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-label { font-size: .65rem; }
  .kpi-foot { font-size: .65rem; }
  .page-heading .btn { width: 100%; }
  .heading-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .heading-actions .btn:first-child:last-child { grid-column: 1 / -1; }
}
