:root {
  color-scheme: light;
  --ink: #15231d;
  --muted: #66756e;
  --line: #d9e1dc;
  --paper: #f4f7f5;
  --card: #ffffff;
  --green: #1f6b46;
  --green-dark: #12372a;
  --amber: #c87512;
  --red: #a93c32;
  --blue: #2d607e;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--paper); color: var(--ink); font-size: 16px; }
button, textarea { font: inherit; }
button { cursor: pointer; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: calc(14px + env(safe-area-inset-top)) 18px 14px; background: var(--green-dark); color: white; box-shadow: 0 5px 18px #10271d33; }
.topbar h1 { margin: 1px 0 0; font-size: 1.34rem; line-height: 1.15; }
.eyebrow { margin: 0; color: #bcd4c8; font-weight: 800; font-size: .72rem; letter-spacing: .11em; }
.connection { display: flex; align-items: center; gap: 7px; max-width: 145px; text-align: right; font-size: .78rem; color: #e2eee8; }
.pulse { width: 9px; height: 9px; flex: 0 0 9px; border-radius: 50%; background: #e0a33d; box-shadow: 0 0 0 4px #e0a33d26; }
.connection.online .pulse { background: #51cf82; box-shadow: 0 0 0 4px #51cf8226; }
main { width: min(760px, 100%); margin: 0 auto; padding: 14px 14px calc(34px + env(safe-area-inset-bottom)); }
.readiness { margin-bottom: 12px; padding: 16px; border: 1px solid #cbd9d1; border-radius: 16px; background: linear-gradient(140deg, #fff, #edf6f1); box-shadow: 0 7px 22px #183a2b0b; }
.readiness.attention { border-color: #e0b16f; background: linear-gradient(140deg, #fff, #fff6e8); }
.readiness.offline { border-color: #dca39d; background: linear-gradient(140deg, #fff, #fff0ed); }
.readiness h2 { margin-top: 3px; }
.readiness > p { margin: 6px 0 14px; color: var(--muted); }
.quick-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.quick-stats div, .quick-stats .stat-link { min-width: 0; padding: 9px; border-radius: 10px; background: #fff; border: 1px solid var(--line); text-align: left; color: inherit; font: inherit; }
.quick-stats strong, .quick-stats span { display: block; }
.quick-stats strong { font-size: 1.2rem; color: var(--green-dark); overflow-wrap: anywhere; }
.quick-stats span { margin-top: 2px; color: var(--muted); font-size: .72rem; font-weight: 700; }
.quick-stats .stat-link { cursor: pointer; box-shadow: inset 0 -3px 0 #d3e7da; }
.quick-stats .stat-link small { display: block; margin-top: 4px; color: var(--blue); font-size: .68rem; font-weight: 800; }
.notification-setup { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; margin-top: 11px; padding: 11px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.notification-setup div { display: grid; gap: 2px; }
.notification-setup span { color: var(--muted); font-size: .78rem; }
.notification-setup button { min-height: 44px; padding: 8px 12px; border: 1px solid var(--green); border-radius: 10px; background: var(--green); color: #fff; font-weight: 800; }
.notification-setup.ready { border-color: #88c89e; background: #eff9f2; }
.notification-setup.blocked { border-color: #dca39d; background: #fff0ed; }
.tabs { position: sticky; top: 78px; z-index: 4; display: grid; grid-template-columns: 1.2fr repeat(6, 1fr); gap: 5px; margin-bottom: 20px; padding: 5px; border: 1px solid var(--line); border-radius: 14px; background: #eef3f0ee; backdrop-filter: blur(8px); }
.tab { min-height: 45px; border: 0; border-radius: 10px; background: transparent; color: #4f5d56; font-weight: 750; }
.tab.active { background: white; color: var(--green-dark); box-shadow: 0 2px 9px #14271e16; }
.badge { display: inline-grid; place-items: center; min-width: 23px; height: 23px; margin-left: 4px; padding: 0 6px; border-radius: 99px; background: var(--amber); color: white; font-size: .75rem; }
.view { display: none; }
.view.active { display: block; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; margin: 0 2px 12px; }
.section-head .eyebrow { color: var(--green); }
.model-badge { padding: 5px 8px; border-radius: 99px; background: #edf1ef; color: var(--muted); font-size: .7rem; font-weight: 800; }
.model-badge.cloud { background: #e5f2ff; color: var(--blue); }
h2 { margin: 2px 0 0; font-size: 1.35rem; }
.icon-button { width: 43px; height: 43px; border: 1px solid var(--line); border-radius: 50%; background: white; color: var(--green-dark); font-size: 1.45rem; }
.ticket-list { display: grid; gap: 13px; }
.ticket { overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--card); box-shadow: 0 7px 22px #183a2b0b; }
.ticket-accent { height: 5px; background: var(--amber); }
.ticket.approved .ticket-accent { background: var(--green); }
.ticket.held .ticket-accent { background: var(--red); }
.ticket-body { padding: 15px; }
.ticket-top { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.ticket-type { margin: 0 0 3px; color: var(--green); font-weight: 800; font-size: .76rem; letter-spacing: .06em; text-transform: uppercase; }
.conservis-type { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 12px 0; padding: 11px 12px; border: 1px solid #c7ddcf; border-radius: 10px; background: #edf8f0; }
.conservis-type span { color: var(--muted); font-size: .78rem; font-weight: 750; }
.conservis-type strong { color: var(--green-dark); text-align: right; }
.load-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 12px; padding: 12px; border: 1px solid #b9d6c4; border-radius: 10px; background: #f3faf5; }
.load-summary div { display: grid; gap: 3px; }
.load-summary span { color: var(--muted); font-size: .78rem; font-weight: 750; }
.load-summary strong { color: var(--green-dark); font-size: 1.08rem; }
.ticket h3 { margin: 0; font-size: 1.23rem; }
.weight { white-space: nowrap; text-align: right; font-size: 1.23rem; font-weight: 850; color: var(--green-dark); }
.meta { display: grid; grid-template-columns: 1fr 1fr; gap: 9px 15px; margin: 16px 0; }
.meta div { min-width: 0; }
.meta dt { color: var(--muted); font-size: .78rem; font-weight: 700; }
.meta dd { margin: 2px 0 0; font-weight: 700; overflow-wrap: anywhere; }
.ticket-details { margin: -5px 0 13px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: #f8faf9; }
.ticket-details summary { cursor: pointer; color: var(--blue); font-weight: 800; }
.ticket-details .meta { margin: 12px 0 2px; }
.note { margin: 0 0 14px; padding: 10px 12px; border-left: 4px solid var(--amber); border-radius: 7px; background: #fff7e8; color: #65430f; font-size: .88rem; }
.waiting-age { display: inline-block; margin-top: 7px; color: var(--amber); font-size: .78rem; font-weight: 800; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.actions button, .chat-form button, .dialog-actions button { min-height: 48px; border: 1px solid var(--green); border-radius: 11px; background: var(--green); color: white; font-weight: 800; }
.actions .hold { border-color: #d1a36a; background: #fff8ed; color: #744b17; }
.actions .correct { grid-column: 1 / -1; border-color: var(--line); background: white; color: var(--blue); }
.empty { padding: 30px 18px; border: 1px dashed #bfcac4; border-radius: 16px; background: #fff8; text-align: center; color: var(--muted); }
.status-pill { display: inline-block; padding: 4px 8px; border-radius: 99px; background: #e9f5ee; color: var(--green); font-size: .77rem; font-weight: 800; text-transform: uppercase; }
.held .status-pill { background: #fff0ed; color: var(--red); }
.chat-messages { display: grid; gap: 10px; min-height: 260px; max-height: 52vh; overflow: auto; padding: 3px 1px 14px; }
.message { width: fit-content; max-width: 88%; padding: 11px 13px; border-radius: 13px 13px 13px 4px; background: white; border: 1px solid var(--line); white-space: pre-wrap; }
.message.user { justify-self: end; border: 0; border-radius: 13px 13px 4px 13px; background: var(--green); color: white; }
.message small { display: block; margin-top: 5px; opacity: .65; }
.chat-form { position: sticky; bottom: 0; display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 9px; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: 0 -5px 22px #183a2b10; }
textarea { width: 100%; resize: vertical; border: 1px solid #b8c4bd; border-radius: 9px; padding: 10px; color: var(--ink); background: white; }
.chat-form textarea { min-height: 48px; resize: none; border: 0; outline: 0; }
.chat-form button { padding: 0 18px; }
.privacy-note { color: var(--muted); font-size: .78rem; line-height: 1.45; }
.system-list { display: grid; gap: 10px; }
.harvest-control { display: grid; gap: 7px; margin-bottom: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.harvest-control h3, .harvest-control p { margin: 0; }
.harvest-control p { color: var(--muted); font-size: .86rem; }
.harvest-control label { color: var(--muted); font-size: .8rem; font-weight: 800; }
.harvest-control input { min-height: 46px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; font: inherit; }
.control-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.control-actions button { min-height: 48px; padding: 8px; border: 1px solid var(--green); border-radius: 11px; background: var(--green); color: #fff; font-weight: 800; }
.control-actions button.secondary { border-color: var(--line); background: #fff; color: var(--green-dark); }
.system-card { display: grid; grid-template-columns: 14px 1fr; gap: 11px; align-items: start; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.system-dot { width: 12px; height: 12px; margin-top: 4px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 4px #a93c3218; }
.system-card.ok .system-dot { background: #2c9b55; box-shadow: 0 0 0 4px #2c9b5518; }
.system-card.warn .system-dot { background: var(--amber); box-shadow: 0 0 0 4px #c8751218; }
.system-card h3 { margin: 0; font-size: 1rem; }
.system-card p { margin: 4px 0 0; color: var(--muted); font-size: .86rem; }
.system-card small { display: block; margin-top: 7px; color: var(--muted); font-size: .74rem; }
dialog { width: min(520px, calc(100% - 24px)); border: 0; border-radius: 18px; padding: 20px; box-shadow: 0 20px 65px #0005; }
dialog::backdrop { background: #10271dbb; backdrop-filter: blur(2px); }
dialog label { display: block; margin: 16px 0 6px; font-weight: 750; }
.form-help { margin: 8px 0 2px; color: var(--muted); font-size: .82rem; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; max-height: 52vh; overflow: auto; padding: 0 3px 8px 0; }
.field-grid label { min-width: 0; margin-top: 10px; color: var(--muted); font-size: .78rem; }
.field-grid input, .field-grid select { width: 100%; min-height: 43px; margin-top: 5px; padding: 8px 9px; border: 1px solid #b8c4bd; border-radius: 9px; background: white; color: var(--ink); font: inherit; }
.manual-ticket-form { display: grid; gap: 14px; padding: 15px; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: 0 7px 22px #183a2b0b; }
.ticket-kind { margin: 0; padding: 0; border: 0; }
.ticket-kind legend { margin-bottom: 10px; color: var(--green-dark); font-weight: 850; }
.ticket-kind-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.ticket-kind-grid label { position: relative; display: block; cursor: pointer; }
.ticket-kind-grid input { position: absolute; opacity: 0; pointer-events: none; }
.ticket-kind-grid span { display: grid; gap: 3px; min-height: 74px; padding: 12px; border: 1px solid #bdcac3; border-radius: 12px; background: #f8faf9; }
.ticket-kind-grid small { color: var(--muted); line-height: 1.25; }
.ticket-kind-grid input:checked + span { border: 2px solid var(--green); padding: 11px; background: #edf8f0; box-shadow: 0 0 0 3px #1f6b4615; }
.manual-fields { max-height: none; overflow: visible; }
.manual-fields label[hidden] { display: none; }
.manual-fields .manual-notes { grid-column: 1 / -1; }
.manual-fields textarea { margin-top: 5px; }
.manual-submit { min-height: 52px; border: 1px solid var(--green); border-radius: 11px; background: var(--green); color: #fff; font-weight: 850; }
.field-grid input.needs-attention, .field-grid select.needs-attention { border: 2px solid var(--amber); background: #fff7e8; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1.35fr; gap: 8px; margin-top: 15px; }
.dialog-actions .secondary { border-color: var(--line); background: white; color: var(--ink); }
.muted { color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 10; width: min(420px, calc(100% - 28px)); padding: 12px 14px; border-radius: 10px; transform: translate(-50%, 130%); background: #17251f; color: white; box-shadow: 0 9px 30px #0004; transition: transform .22s ease; }
.toast.show { transform: translate(-50%, 0); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
@media (max-width: 430px) { .tab { font-size: .82rem; } .badge { min-width: 20px; height: 20px; } }
@media (max-width: 430px) { .field-grid { grid-template-columns: 1fr; max-height: 55vh; } }
@media (max-width: 600px) {
  body { padding-bottom: env(safe-area-inset-bottom); }
  main { padding-bottom: 98px; }
  .tabs { position: fixed; inset: auto 8px calc(8px + env(safe-area-inset-bottom)) 8px; top: auto; z-index: 20; margin: 0; grid-template-columns: repeat(7, minmax(0, 1fr)); box-shadow: 0 10px 34px #07170f55; }
  .tab { min-width: 0; padding: 5px 2px; font-size: .74rem; }
  .readiness { margin-top: 4px; }
  .actions button { min-height: 54px; font-size: 1rem; }
  .notification-setup { grid-template-columns: 1fr; }
  .notification-setup button { width: 100%; }
  .ticket-kind-grid { grid-template-columns: 1fr; }
}
@media (min-width: 680px) { main { padding-top: 22px; } .ticket-body { padding: 19px; } .tabs { top: 86px; } }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
