:root {
  --ink: #14213d;
  --ink-soft: #4a566e;
  --signal: #f26b0f;
  --signal-dark: #c9540a;
  --paper: #edf0f5;
  --panel: #ffffff;
  --line: #d9dfe9;
  --warn: #b42318;
  --ok: #1a7f4b;
  --radius: 10px;
  --bs-body-font-family: 'Open Sans', system-ui, sans-serif;
  --bs-body-color: var(--ink);
  --bs-body-bg: var(--paper);
  --bs-primary: var(--ink);
}

html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--bs-body-font-family); background: var(--paper); color: var(--ink); font-size: 1rem; }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.005em; }
a { color: var(--ink); }
:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; }

.btn-brand { background: var(--signal); border-color: var(--signal); color: #fff; font-weight: 600; }
.btn-brand:hover, .btn-brand:focus { background: var(--signal-dark); border-color: var(--signal-dark); color: #fff; }
.btn-brand:disabled { background: #e7a579; border-color: #e7a579; color: #fff; }
.btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; }
.btn-sm { min-height: 36px; }
.form-control, .form-select { min-height: 44px; border-color: var(--line); }
.form-control:focus, .form-select:focus { border-color: var(--signal); box-shadow: 0 0 0 .2rem rgba(242,107,15,.2); }
.form-control[readonly] { background: #f3f5f9; font-weight: 600; }
.form-label { font-weight: 500; font-size: .9rem; margin-bottom: .25rem; color: var(--ink-soft); }
.req { color: var(--warn); }
.field-error { color: var(--warn); font-size: .85rem; }
.muted-note { color: var(--ink-soft); font-size: .88rem; }

/* ---------- top bar ---------- */
.topbar { background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 30; padding-top: env(safe-area-inset-top); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 56px; }
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; text-decoration: none; min-width: 0; }
.brand-logo { height: 34px; width: auto; max-width: 90px; object-fit: contain; background: #fff; border-radius: 6px; padding: 2px 4px; }
.brand-name { font-family: 'Open Sans', system-ui, sans-serif; font-weight: 700; font-size: 1.2rem; letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-user { display: flex; align-items: center; gap: .75rem; font-size: .95rem; }

.page { padding-top: 1.25rem; padding-bottom: 7rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem 1.5rem; margin-bottom: 1rem; }
.page-title { font-size: 1.6rem; margin: 0; }
.page-sub { margin: .15rem 0 0; color: var(--ink-soft); }
.back-link { display: inline-block; font-size: .9rem; color: var(--ink-soft); text-decoration: none; margin-bottom: .25rem; }
.back-link:hover { color: var(--signal-dark); }
.search-box { position: relative; width: 100%; max-width: 360px; }
.search-box i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-soft); }
.search-box input { padding-left: 2.2rem; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 1fr; }
.login-hero { background: var(--ink); color: #fff; padding: 2.5rem 1.5rem 3.5rem; }
.login-hero h1 { font-family: 'Open Sans', system-ui, sans-serif; font-size: clamp(2.2rem, 7vw, 3.6rem); line-height: 1.02; margin: 1rem 0 .75rem; font-weight: 700; }
.login-hero p { max-width: 34ch; color: #c5cde0; margin: 0; }
.hero-mark { width: 52px; height: 52px; border-radius: 12px; background: var(--signal); display: grid; place-items: center; font-size: 1.6rem; }
.login-card { background: var(--panel); margin: -1.75rem 1rem 1.5rem; border-radius: 14px; padding: 1.5rem 1.25rem; box-shadow: 0 10px 30px rgba(20,33,61,.12); align-self: start; }
.login-card h2 { font-size: 1.3rem; margin-bottom: 1rem; }

@media (min-width: 900px) {
  .login-wrap { grid-template-columns: 1.1fr 1fr; }
  .login-hero { display: flex; flex-direction: column; justify-content: center; padding: 4rem; }
  .login-card { margin: auto; width: min(420px, 90%); padding: 2rem; align-self: center; }
}

/* ---------- complaint tickets ---------- */
.ticket-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 720px) { .ticket-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { .ticket-grid { grid-template-columns: repeat(3, 1fr); } }

.ticket { background: var(--panel); border: 1px solid var(--line); border-left: 6px solid var(--ink); border-radius: var(--radius); padding: 1rem 1rem .9rem; display: flex; flex-direction: column; }
.ticket.is-overdue { border-left-color: var(--warn); }
.ticket-top { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; }
.ticket-no { font-family: 'Open Sans', system-ui, sans-serif; font-size: 1.7rem; font-weight: 700; line-height: 1; }
.ticket-date { font-size: .82rem; color: var(--ink-soft); margin-top: .2rem; }
.chip { display: inline-block; padding: .2rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.chip-type { background: #fde8d8; color: var(--signal-dark); }
.ticket-cust { font-size: 1.1rem; margin: .8rem 0 .15rem; }
.ticket-addr { color: var(--ink-soft); font-size: .92rem; margin: 0 0 .75rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ticket-facts { margin: 0 0 1rem; border-top: 1px dashed var(--line); padding-top: .6rem; display: grid; gap: .4rem; }
.ticket-facts div { display: grid; grid-template-columns: 6.2rem 1fr; gap: .5rem; }
.ticket-facts dt { font-weight: 500; color: var(--ink-soft); font-size: .88rem; }
.ticket-facts dd { margin: 0; font-weight: 500; }
.late { color: var(--warn); font-size: .8rem; font-weight: 700; margin-left: .35rem; }
.ticket-actions { display: flex; gap: .5rem; margin-top: auto; }
.ticket-actions .btn-outline-dark { width: 44px; padding: 0; }

.empty { text-align: center; color: var(--ink-soft); padding: 3rem 1rem; }
.empty i { font-size: 2.5rem; color: var(--ok); }
.empty h2 { font-size: 1.2rem; color: var(--ink); margin-top: .5rem; }

/* ---------- solve screen ---------- */
.info-grid { display: grid; gap: 1rem; margin-bottom: 1rem; grid-template-columns: 1fr; }
@media (min-width: 800px) { .info-grid { grid-template-columns: 1fr 1fr; } }
.info-card { background: #fff6e8; border: 1px solid #f3dcb0; border-radius: var(--radius); padding: 1rem; }
.info-card h2 { font-size: 1.1rem; margin-bottom: .6rem; padding-bottom: .5rem; border-bottom: 1px solid #f0d9ab; }
.info-card dl { display: grid; grid-template-columns: 8.5rem 1fr; gap: .3rem .75rem; margin: 0; font-size: .93rem; }
.info-card dt { font-weight: 600; }
.info-card dd { margin: 0; overflow-wrap: anywhere; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.panel-title { font-size: 1.05rem; margin-bottom: .8rem; }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg label { text-align: center; padding: .7rem .5rem; cursor: pointer; font-weight: 600; border-right: 1px solid var(--line); min-height: 44px; }
.seg label:last-of-type { border-right: 0; }
.seg input:checked + label { background: var(--ink); color: #fff; }
.seg input:focus-visible + label { outline: 3px solid var(--signal); outline-offset: -3px; }

.form-grid { display: grid; gap: .9rem 1rem; grid-template-columns: 1fr; }
@media (min-width: 700px) { .form-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1000px) { .form-grid { grid-template-columns: repeat(3, 1fr); } }

.item-entry { display: grid; gap: .7rem; grid-template-columns: 1fr 1fr; margin-bottom: .8rem; }
.item-entry > div:nth-child(1), .item-entry > div:nth-child(2), .item-entry .item-add { grid-column: 1 / -1; }
@media (min-width: 900px) {
  .item-entry { grid-template-columns: 1.2fr 1.6fr 1fr .6fr .8fr 1fr 1fr auto; align-items: end; }
  .item-entry > div:nth-child(1), .item-entry > div:nth-child(2), .item-entry .item-add { grid-column: auto; }
}
.items-list { display: grid; gap: .5rem; }
.item-row { display: grid; grid-template-columns: 1fr auto; gap: .4rem .75rem; border: 1px solid var(--line); border-radius: 8px; padding: .6rem .75rem; align-items: center; }
.item-main { display: grid; min-width: 0; }
.item-main .muted-note { overflow-wrap: anywhere; }
.item-calc { display: flex; flex-direction: column; align-items: flex-end; font-size: .88rem; color: var(--ink-soft); }
.item-calc strong { color: var(--ink); font-size: 1rem; }
.item-btns { grid-column: 1 / -1; display: flex; gap: .4rem; justify-content: flex-end; }
@media (min-width: 700px) {
  .item-row { grid-template-columns: 1fr auto auto; }
  .item-btns { grid-column: auto; }
}

.multi-btn { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; background-color: #fff; }
.multi .placeholder-on { color: #6c757d; }
.multi-menu { width: 100%; max-height: 260px; overflow-y: auto; padding: .25rem 0; }
.multi-opt { display: flex; align-items: center; gap: .6rem; padding: .55rem .9rem; cursor: pointer; min-height: 44px; }
.multi-opt:hover { background: #f3f5f9; }
.multi-opt input { width: 1.15rem; height: 1.15rem; accent-color: var(--signal); }

.check-row { display: grid; gap: .3rem; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.check-row:last-child { border-bottom: 0; }
@media (min-width: 800px) { .check-row { grid-template-columns: 1fr 1fr; align-items: center; gap: 1rem; } }

.photo-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; margin-bottom: .6rem; }
@media (min-width: 700px) { .photo-grid { grid-template-columns: repeat(5, 1fr); } }
.photo-box { aspect-ratio: 4 / 3; border: 2px dashed var(--line); border-radius: 8px; display: grid; place-items: center; font-size: 2rem; color: var(--ink-soft); overflow: hidden; background: #f8f9fc; }
.photo-box img { width: 100%; height: 100%; object-fit: cover; }

.sig-wrap { position: relative; }
#sig { width: 100%; height: 180px; border: 1px solid var(--line); border-radius: 8px; background: #fafbfd; touch-action: none; display: block; }
#sigClear { position: absolute; right: 8px; top: 8px; background: #fff; }

.submit-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: #fff; border-top: 1px solid var(--line); padding: .75rem 1rem calc(.75rem + env(safe-area-inset-bottom)); display: flex; align-items: center; justify-content: space-between; gap: 1rem; box-shadow: 0 -6px 20px rgba(20,33,61,.08); }
.submit-bar .btn { flex: 1; max-width: 420px; }
.geo { font-size: .85rem; color: var(--ink-soft); display: none; }
@media (min-width: 700px) { .geo { display: block; } .submit-bar { padding-left: max(1rem, calc((100vw - 1320px) / 2 + 12px)); padding-right: max(1rem, calc((100vw - 1320px) / 2 + 12px)); } .submit-bar .btn { flex: 0 0 auto; min-width: 260px; } }

.toast-wrap { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 1080; }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }

/* ======================================================================
   Visual refresh: dashboard, ticket cards, solve form, details
   ====================================================================== */
:root {
  --paper: #eef1f7;
  --hold: #d98e04;   --hold-soft: #fff3d6;
  --done: #1f8f5a;   --done-soft: #dff3e7;
  --info: #2f6fed;   --info-soft: #e3ecff;
  --shadow-sm: 0 1px 2px rgba(20,33,61,.06), 0 2px 8px rgba(20,33,61,.05);
  --shadow-md: 0 8px 24px rgba(20,33,61,.12);
  --radius: 14px;
}
body { background: radial-gradient(1200px 400px at 50% -120px, #dfe6f5 0, transparent 70%), var(--paper); }
.topbar { background: linear-gradient(135deg, #14213d 0%, #1d2f5a 100%); box-shadow: 0 2px 12px rgba(20,33,61,.25); }
.btn { border-radius: 10px; }
.btn-brand { background: linear-gradient(135deg, #ff8a3d, var(--signal)); border: 0; box-shadow: 0 4px 12px rgba(242,107,15,.3); }
.btn-brand:hover { background: linear-gradient(135deg, var(--signal), var(--signal-dark)); }
.form-control, .form-select { border-radius: 10px; background-color: #fbfcfe; }

/* ---- hero ---- */
.hero { position: relative; overflow: hidden; border-radius: 20px; padding: 1.4rem 1.25rem 1.25rem; color: #fff; margin-bottom: 1.1rem;
  background: linear-gradient(135deg, #14213d 0%, #24407e 60%, #3a5bb0 100%); box-shadow: var(--shadow-md); }
.hero::before, .hero::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255,255,255,.07); }
.hero::before { width: 240px; height: 240px; right: -70px; top: -90px; }
.hero::after { width: 140px; height: 140px; right: 90px; bottom: -80px; background: rgba(242,107,15,.25); }
.hero > * { position: relative; z-index: 1; }
.hero-hello { font-size: .9rem; opacity: .8; margin: 0; }
.hero-title { font-family: 'Open Sans', system-ui, sans-serif; font-size: clamp(1.7rem, 5vw, 2.4rem); font-weight: 700; margin: .1rem 0 .2rem; line-height: 1.05; }
.hero-sub { margin: 0; opacity: .85; }
.hero .back-link { color: rgba(255,255,255,.8); }
.hero .back-link:hover { color: #fff; }
.hero-row { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; margin-top: .9rem; }
.hero .search-box { max-width: 420px; }
.hero .search-box input { border: 0; background: rgba(255,255,255,.95); box-shadow: 0 2px 10px rgba(0,0,0,.15); }

/* ---- stat tiles (also the tabs) ---- */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin-bottom: 1.1rem; }
.stat { display: flex; flex-direction: column; gap: .15rem; padding: .85rem .9rem; border-radius: var(--radius); background: var(--panel); text-decoration: none; color: var(--ink);
  border: 2px solid transparent; box-shadow: var(--shadow-sm); transition: transform .15s, box-shadow .15s; position: relative; overflow: hidden; }
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 1.05rem; margin-bottom: .25rem; }
.stat-num { font-family: 'Open Sans', system-ui, sans-serif; font-size: 2rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .85rem; font-weight: 600; color: var(--ink-soft); }
.stat.s-assigned .stat-ico { background: var(--info-soft); color: var(--info); }
.stat.s-hold .stat-ico { background: var(--hold-soft); color: var(--hold); }
.stat.s-solved .stat-ico { background: var(--done-soft); color: var(--done); }
.stat.active.s-assigned { border-color: var(--info); }
.stat.active.s-hold { border-color: var(--hold); }
.stat.active.s-solved { border-color: var(--done); }
.stat.active::after { content: ""; position: absolute; right: 10px; top: 10px; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.stat.active.s-assigned::after { background: var(--info); }
.stat.active.s-hold::after { background: var(--hold); }
.stat.active.s-solved::after { background: var(--done); }
@media (max-width: 420px) { .stat { padding: .7rem .6rem; } .stat-num { font-size: 1.7rem; } .stat-label { font-size: .78rem; } }

.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 0 .7rem; }
.section-head h2 { font-size: 1.15rem; margin: 0; }

/* ---- ticket cards ---- */
.ticket { border: 0; border-top: 5px solid var(--info); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 1.05rem 1.05rem .95rem; transition: transform .15s, box-shadow .15s; }
.ticket:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.ticket.is-overdue { border-top-color: var(--warn); }
.ticket.is-hold { border-top-color: var(--hold); }
.ticket.is-solved { border-top-color: var(--done); }
.ticket-no { font-size: 1.55rem; }
.chip { padding: .25rem .7rem; }
.chip-type { background: var(--info-soft); color: #1c4bb5; }
.chip-hold { background: var(--hold-soft); color: #8a5a00; }
.chip-done { background: var(--done-soft); color: #166b43; }
.chip-late { background: #fde4e1; color: var(--warn); }
.ticket-cust { display: flex; align-items: center; gap: .6rem; font-size: 1.1rem; margin: .85rem 0 .35rem; }
.avatar { flex: 0 0 38px; width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; color: #fff; background: linear-gradient(135deg, #3a5bb0, #14213d); }
.is-hold .avatar { background: linear-gradient(135deg, #f0ac26, #c47a00); }
.is-solved .avatar { background: linear-gradient(135deg, #34b27a, #166b43); }
.ticket-addr i { color: var(--signal); }
.ticket-facts { border-top: 1px solid var(--line); background: #f7f9fd; margin-left: -1.05rem; margin-right: -1.05rem; padding: .75rem 1.05rem; }
.ticket-facts div { grid-template-columns: 1.4rem 1fr; align-items: start; }
.ticket-facts i { color: var(--ink-soft); }
.ticket-facts dd { font-size: .93rem; }
.ticket-facts .k { display: block; font-size: .72rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-soft); }
.ticket-actions .btn-outline-dark { border-color: var(--line); color: var(--ink); background: #fff; border-radius: 12px; }
.ticket-actions .btn-outline-dark:hover { background: var(--ink); color: #fff; }
.btn-view { background: var(--done-soft); border: 0; color: #166b43; font-weight: 600; }
.btn-view:hover { background: var(--done); color: #fff; }
.empty { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow-sm); }

/* ---- solve form ---- */
.hero-ticket { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; margin-top: .3rem; }
.hero-ticket .chip { background: rgba(255,255,255,.18); color: #fff; }
.hero-ticket .chip-hold { background: var(--hold); color: #fff; }
.hero-ticket .chip-done { background: var(--done); color: #fff; }

.info-card { background: var(--panel); border: 0; border-radius: var(--radius); box-shadow: var(--shadow-sm); border-top: 4px solid var(--info); }
.info-grid .info-card:nth-child(2) { border-top-color: var(--signal); }
.info-card h2 { font-size: 1.05rem; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: .5rem; }
.info-card h2 i { color: var(--info); }
.info-grid .info-card:nth-child(2) h2 i { color: var(--signal); }
.info-card dt { color: var(--ink-soft); font-weight: 500; }
.info-card dd { font-weight: 600; }

.panel { border: 0; border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 1.1rem 1.1rem 1.15rem; }
.panel-title { display: flex; align-items: center; gap: .6rem; font-size: 1.05rem; margin-bottom: 1rem; padding-bottom: .7rem; border-bottom: 1px solid var(--line); }
.panel-title .pi { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: #fde8d8; color: var(--signal-dark); font-size: 1rem; flex: 0 0 32px; }

.seg { gap: .5rem; border: 0; overflow: visible; }
.seg label { border: 2px solid var(--line); border-radius: 12px; background: #fff; display: flex; align-items: center; justify-content: center; gap: .4rem; transition: all .15s; }
.seg label:hover { border-color: #b9c3d8; }
.seg input[value="6"]:checked + label { background: var(--done-soft); border-color: var(--done); color: #166b43; }
.seg input[value="3"]:checked + label { background: var(--hold-soft); border-color: var(--hold); color: #8a5a00; }
.seg input[value="5"]:checked + label { background: #fde4e1; border-color: var(--warn); color: var(--warn); }
.seg input:checked + label::before { content: "\F26E"; font-family: bootstrap-icons; }

.item-row { border-radius: 12px; background: #f7f9fd; border-color: transparent; }
.photo-box { border-radius: 12px; border-color: #c9d2e6; background: #f7f9fd; transition: border-color .15s, background .15s; }
.photo-box:hover { border-color: var(--signal); background: #fff7f0; }
#sig { border-radius: 12px; border: 2px dashed #c9d2e6; background: #fbfcfe; }
#totalItems, #grand, #balance { font-family: 'Open Sans', system-ui, sans-serif; font-size: 1.25rem; }
#grand { background: var(--done-soft); color: #166b43; }
.submit-bar { background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-top: 0; box-shadow: 0 -8px 24px rgba(20,33,61,.12); }
.submit-bar .btn { border-radius: 12px; }

/* ---- details (view only) ---- */
.readonly-banner { display: flex; align-items: center; gap: .6rem; background: var(--done-soft); color: #166b43; border-radius: 12px; padding: .7rem 1rem; margin-bottom: 1rem; font-weight: 600; }

/* Open Sans reads wider than Barlow: trim display sizes and letter-spacing */
body { font-size: .95rem; }
.ticket-no, .hero-title, .stat-num, .brand-name { letter-spacing: -.01em; }
.ticket-no { font-size: 1.35rem; }
.stat-num { font-size: 1.8rem; }
.hero-title { font-size: clamp(1.5rem, 4.5vw, 2.1rem); }
.login-hero h1 { font-size: clamp(2rem, 6vw, 3.1rem); }

@media (min-width: 900px) {
  .item-entry { grid-template-columns: 1.2fr 1.6fr 1.1fr .7fr .6fr .8fr 1fr 1fr auto; }
}
#itAvl { font-weight: 700; text-align: center; }

#itAvl { background: var(--info-soft); color: #1c4bb5; }
.avl-chip { display: inline-block; margin-left: .35rem; padding: 0 .45rem; border-radius: 999px; background: var(--info-soft); color: #1c4bb5; font-size: .78rem; font-weight: 600; }
