:root {
  color-scheme: light;
  --bg: #f3f5f2;
  --surface: #ffffff;
  --surface-2: #edf1ed;
  --ink: #17201d;
  --muted: #68736f;
  --line: #d8dfda;
  --green: #087a55;
  --green-dark: #075d43;
  --green-soft: #dff4e9;
  --amber: #aa6400;
  --amber-soft: #fff0cf;
  --red: #bb3038;
  --red-soft: #ffe8e8;
  --blue: #245a9a;
  --shadow: 0 14px 40px rgba(23, 32, 29, .08);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; color: var(--ink); background: var(--bg); font-size: 14px; letter-spacing: 0; }
button, input, textarea, select { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid rgba(36, 90, 154, .25); outline-offset: 2px; }
.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; }
.is-hidden { display: none !important; }

.app-header { height: 68px; padding: 0 max(24px, calc((100vw - 1440px) / 2)); display: flex; align-items: center; justify-content: space-between; background: var(--ink); color: white; border-bottom: 1px solid #29332f; }
.brand { display: flex; gap: 11px; align-items: center; color: white; text-decoration: none; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; background: #e3f3bd; color: var(--ink); border-radius: 5px; font-size: 17px; font-weight: 800; }
.brand-mark.large { width: 52px; height: 52px; font-size: 25px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; }
.brand small { margin-top: 2px; color: #aebbb5; font-size: 11px; }
.header-actions, .button-row { display: flex; align-items: center; gap: 8px; }
.service-state { display: flex; align-items: center; gap: 7px; color: #c2ccc7; font-size: 12px; margin-right: 8px; }
.service-state i { width: 7px; height: 7px; border-radius: 50%; background: #73807a; box-shadow: 0 0 0 4px rgba(115, 128, 122, .12); }
.service-state i.online { background: #5ce0a7; box-shadow: 0 0 0 4px rgba(92, 224, 167, .14); }

.page-shell { max-width: 1440px; margin: 0 auto; padding: 32px 24px 56px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; }
.eyebrow { display: block; margin-bottom: 7px; color: var(--green); font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.page-heading h1 { margin: 0; font-size: 38px; line-height: 1.12; letter-spacing: 0; }
.page-heading p { margin: 9px 0 0; color: var(--muted); }
.last-update { color: var(--muted); font-size: 12px; }

.inventory-strip { display: grid; grid-template-columns: minmax(260px, 1.4fr) repeat(3, 1fr); min-height: 132px; margin-bottom: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; overflow: hidden; box-shadow: 0 6px 20px rgba(23, 32, 29, .04); }
.inventory-strip > div { padding: 23px 26px; border-left: 1px solid var(--line); display: flex; flex-direction: column; justify-content: center; }
.inventory-strip > div:first-child { border-left: 0; }
.inventory-strip span { color: var(--muted); font-size: 12px; font-weight: 650; }
.inventory-strip strong { margin-top: 8px; font-size: 30px; line-height: 1; font-variant-numeric: tabular-nums; }
.inventory-strip small { margin-top: 9px; color: var(--green); }
.inventory-primary { background: var(--green-soft); }
.inventory-primary strong { color: var(--green-dark); font-size: 46px; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.main-column, .side-column { display: grid; gap: 20px; }
.tool-panel, .task-panel, .activity-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 7px; }
.add-panel { padding: 22px; }
.section-title { min-height: 35px; margin-bottom: 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.section-title > div { display: flex; align-items: center; gap: 9px; min-width: 0; }
.section-title h2 { margin: 0; font-size: 16px; line-height: 1.2; }
.section-title > span { color: var(--muted); font-size: 12px; }
.step { width: 25px; height: 25px; display: grid; place-items: center; background: var(--surface-2); color: var(--green-dark); border-radius: 4px; font-size: 10px; font-weight: 800; }
.count-badge { min-width: 24px; padding: 3px 7px; color: var(--muted); background: var(--surface-2); border-radius: 4px; text-align: center; font-size: 11px; }

textarea, input[type="url"], input[type="text"], input[type="password"], input[type="number"] { width: 100%; color: var(--ink); background: #fbfcfb; border: 1px solid #cbd4ce; border-radius: 5px; }
textarea { min-height: 104px; resize: vertical; padding: 13px 14px; line-height: 1.6; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
textarea:focus, input:focus, select:focus { border-color: var(--green); background: white; }
.form-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 12px; }
.form-footer > span, .field-note { color: var(--muted); font-size: 11px; }
.button { min-height: 36px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 13px; border: 1px solid transparent; border-radius: 5px; text-decoration: none; cursor: pointer; font-weight: 700; font-size: 12px; transition: background .15s, border-color .15s, opacity .15s; }
.button svg { width: 15px; height: 15px; }
.button.primary { color: white; background: var(--green); }
.button.primary:hover { background: var(--green-dark); }
.button.secondary { color: var(--ink); background: white; border-color: var(--line); }
.button.secondary:hover { border-color: #9eaaa3; background: var(--surface-2); }
.button.danger { color: var(--red); background: white; border-color: #e8b8bb; }
.button.full { width: 100%; min-height: 42px; }
.button:disabled, .is-disabled { pointer-events: none; opacity: .45; }
.icon-button, .icon-text { min-width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 0; border-radius: 5px; cursor: pointer; }
.icon-button svg, .icon-text svg { width: 16px; height: 16px; }
.icon-text { padding: 0 11px; }
.ghost { color: inherit; background: transparent; }
.app-header .ghost:hover { background: rgba(255,255,255,.09); }
.row-actions .ghost:hover, .dialog-shell .ghost:hover { background: var(--surface-2); }
.danger-ghost { color: var(--red); background: transparent; }
.danger-ghost:hover { background: var(--red-soft); }

.codes-panel { overflow: hidden; }
.table-title { padding: 18px 20px 2px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 820px; }
th { padding: 10px 12px; color: var(--muted); background: #f8faf8; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); text-align: left; font-size: 10px; text-transform: uppercase; }
td { padding: 12px; border-bottom: 1px solid #e7ece8; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcfb; }
.check-cell { width: 44px; padding-left: 18px; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--green); }
.code-value { display: flex; align-items: center; gap: 4px; max-width: 390px; }
.code-value code { overflow: hidden; text-overflow: ellipsis; color: #26312d; font-size: 12px; white-space: nowrap; }
.code-value .icon-button { min-width: 28px; height: 28px; color: var(--muted); }
.row-error { display: block; max-width: 390px; margin-top: 5px; color: var(--red); font-size: 11px; line-height: 1.4; overflow-wrap: anywhere; }
.status-chip { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 4px; font-size: 10px; font-weight: 800; white-space: nowrap; }
.status-chip.waiting, .status-chip.idle, .status-chip.muted { color: #56615c; background: #edf0ee; }
.status-chip.working { color: var(--blue); background: #e7f0fb; }
.status-chip.success { color: var(--green-dark); background: var(--green-soft); }
.status-chip.error { color: var(--red); background: var(--red-soft); }
.status-chip.warning { color: var(--amber); background: var(--amber-soft); }
.time-cell { color: var(--muted); font-size: 11px; white-space: nowrap; }
.actions-cell { text-align: right; }
.row-actions { width: 120px; text-align: right; white-space: nowrap; }
.row-actions > * { display: inline-flex; vertical-align: middle; color: var(--muted); }
.empty-state { padding: 56px 24px; display: flex; flex-direction: column; align-items: center; color: var(--muted); }
.empty-state[hidden] { display: none; }
.empty-state svg { width: 28px; height: 28px; margin-bottom: 12px; color: #9ca7a1; }
.empty-state strong { color: var(--ink); }
.empty-state span { margin-top: 5px; font-size: 12px; }

.task-panel { padding: 20px; border-top: 3px solid var(--green); }
.progress-block { padding: 15px; background: #f7f9f7; border: 1px solid var(--line); border-radius: 5px; }
.progress-copy { display: flex; align-items: flex-end; justify-content: space-between; }
.progress-copy span { color: var(--muted); font-size: 11px; }
.progress-copy strong { font-size: 21px; font-variant-numeric: tabular-nums; }
.progress-track { height: 7px; margin-top: 13px; overflow: hidden; background: #dce3de; border-radius: 3px; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--green); transition: width .25s ease; }
.task-message { min-height: 38px; margin: 13px 0 18px; color: var(--muted); line-height: 1.45; font-size: 12px; }
.task-panel form > label { display: block; margin: 13px 0 6px; font-size: 11px; font-weight: 750; }
.number-field { height: 40px; display: grid; grid-template-columns: 40px 1fr 40px; border: 1px solid #cbd4ce; border-radius: 5px; overflow: hidden; }
.number-field button { border: 0; background: var(--surface-2); color: var(--ink); cursor: pointer; }
.number-field button:hover { background: #dfe5e1; }
.number-field button svg { width: 14px; }
.number-field input { min-width: 0; border: 0; border-left: 1px solid #cbd4ce; border-right: 1px solid #cbd4ce; border-radius: 0; text-align: center; font-weight: 800; -moz-appearance: textfield; }
.number-field input::-webkit-inner-spin-button { -webkit-appearance: none; }
.select-wrap { position: relative; }
.select-wrap select { width: 100%; height: 40px; padding: 0 34px 0 12px; color: var(--ink); background: white; border: 1px solid #cbd4ce; border-radius: 5px; appearance: none; }
.select-wrap svg { position: absolute; right: 11px; top: 12px; width: 15px; pointer-events: none; color: var(--muted); }
.selection-note { margin: 13px 0; color: var(--muted); font-size: 11px; }
.selection-note strong { color: var(--green-dark); }
.task-panel .full + .full { margin-top: 8px; }
.activity-panel { padding: 20px; }
.activity-panel .section-title svg { width: 16px; color: var(--green); }
.rules { margin: 0; padding: 0; list-style: none; }
.rules li { display: grid; grid-template-columns: 25px 1fr; gap: 10px; padding: 10px 0; border-top: 1px solid #e7ece8; }
.rules li:first-child { border-top: 0; }
.rules li > span { width: 22px; height: 22px; display: grid; place-items: center; background: var(--surface-2); border-radius: 4px; color: var(--green-dark); font-size: 10px; font-weight: 800; }
.rules p { margin: 1px 0 0; color: var(--muted); line-height: 1.45; font-size: 11px; }
.rules code { color: var(--ink); }

dialog { width: min(560px, calc(100vw - 28px)); padding: 0; color: var(--ink); background: transparent; border: 0; border-radius: 7px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(12, 18, 16, .64); backdrop-filter: blur(3px); }
.dialog-shell { padding: 24px; background: white; border-radius: 7px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.dialog-heading h2 { margin: 0; font-size: 19px; }
.dialog-shell > label:not(.toggle-row), .field-grid label { display: block; margin: 13px 0 6px; font-size: 11px; font-weight: 750; }
.dialog-shell input[type="url"], .dialog-shell input[type="text"], .dialog-shell input[type="password"], .dialog-shell input[type="number"] { height: 40px; padding: 0 11px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.proxy-grid { grid-template-columns: minmax(0, 1fr) 110px; }
.field-note { margin: 5px 0 0; }
.toggle-row { margin-top: 18px; padding: 13px; display: flex; align-items: center; justify-content: space-between; gap: 16px; background: var(--surface-2); border-radius: 5px; cursor: pointer; }
.toggle-row strong, .toggle-row small { display: block; }
.toggle-row strong { font-size: 12px; }
.toggle-row small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.toggle-row input { width: 36px; height: 20px; accent-color: var(--green); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }

.toast-region { position: fixed; z-index: 50; right: 20px; bottom: 20px; display: grid; gap: 8px; }
.toast { min-width: 260px; max-width: min(420px, calc(100vw - 32px)); padding: 12px 14px; display: flex; align-items: flex-start; gap: 9px; color: white; background: var(--ink); border-radius: 5px; box-shadow: var(--shadow); animation: toast-in .18s ease-out; }
.toast.error { background: #8f252b; }
.toast svg { width: 17px; min-width: 17px; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin .8s linear infinite; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; color: white; background: #17201d; }
.login-shell { width: min(900px, 100%); min-height: 510px; display: grid; grid-template-columns: 1fr 1fr; overflow: hidden; background: white; border: 1px solid #34403b; border-radius: 7px; box-shadow: 0 30px 80px rgba(0,0,0,.28); }
.login-brand { padding: 54px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; background: #22312c; }
.login-brand .eyebrow { margin-top: 30px; color: #badd91; }
.login-brand h1 { margin: 0; font-size: 52px; letter-spacing: 0; }
.login-brand > p:last-of-type { margin: 10px 0 0; color: #b7c2bd; }
.login-status { margin-top: 66px; display: flex; align-items: center; gap: 8px; color: #b7c2bd; font-size: 11px; }
.login-status i { width: 7px; height: 7px; border-radius: 50%; background: #5ce0a7; }
.login-form-wrap { padding: 54px; display: flex; align-items: center; color: var(--ink); }
.login-form-wrap form { width: 100%; }
.form-heading { display: flex; gap: 13px; align-items: flex-start; margin-bottom: 34px; }
.form-heading > svg { width: 24px; height: 24px; color: var(--green); }
.form-heading h2 { margin: 0; font-size: 21px; }
.form-heading p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.login-form-wrap label { display: block; margin-bottom: 7px; font-size: 11px; font-weight: 750; }
.password-wrap { height: 44px; display: grid; grid-template-columns: 38px 1fr 38px; align-items: center; border: 1px solid #cbd4ce; border-radius: 5px; }
.password-wrap > svg { width: 15px; justify-self: center; color: var(--muted); }
.password-wrap input { height: 42px; padding: 0; border: 0; background: transparent; }
.password-wrap button { height: 42px; display: grid; place-items: center; color: var(--muted); background: transparent; border: 0; cursor: pointer; }
.password-wrap button svg { width: 16px; }
.login-error { min-height: 36px; margin: 8px 0 4px; color: var(--red); font-size: 11px; }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .side-column { grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr); }
  .inventory-strip { grid-template-columns: 1.25fr repeat(3, 1fr); }
  .inventory-strip > div { padding: 20px; }
}

@media (max-width: 720px) {
  .app-header { height: 60px; padding: 0 14px; }
  .brand small, .service-state, .icon-text span { display: none; }
  .icon-text { width: 34px; padding: 0; }
  .page-shell { padding: 22px 14px 40px; }
  .page-heading { align-items: flex-start; gap: 14px; }
  .page-heading h1 { font-size: 27px; }
  .last-update { max-width: 100px; text-align: right; line-height: 1.4; }
  .inventory-strip { grid-template-columns: 1fr 1fr; }
  .inventory-strip > div { min-height: 104px; border-left: 1px solid var(--line); border-top: 1px solid var(--line); }
  .inventory-strip > div:nth-child(1), .inventory-strip > div:nth-child(2) { border-top: 0; }
  .inventory-strip > div:nth-child(odd) { border-left: 0; }
  .inventory-primary strong { font-size: 38px; }
  .form-footer, .table-title { align-items: stretch; flex-direction: column; }
  .form-footer .button-row, .table-title .button-row { justify-content: flex-end; }
  .side-column { grid-template-columns: 1fr; }
  .login-page { padding: 14px; }
  .login-shell { min-height: 0; grid-template-columns: 1fr; }
  .login-brand { padding: 30px; }
  .login-brand h1 { font-size: 38px; }
  .login-brand .eyebrow { margin-top: 16px; }
  .login-status { margin-top: 24px; }
  .login-form-wrap { padding: 32px 28px; }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions .button { width: 100%; }
  .field-grid, .proxy-grid { grid-template-columns: 1fr; gap: 0; }
}

@media (max-width: 430px) {
  .page-heading p { max-width: 230px; line-height: 1.45; }
  .inventory-strip > div { padding: 16px; }
  .inventory-strip strong { font-size: 25px; }
  .inventory-primary strong { font-size: 34px; }
  .add-panel, .task-panel, .activity-panel { padding: 17px; }
  .button-row { flex-wrap: wrap; }
  .toast-region { right: 10px; bottom: 10px; }
}
