:root {
    --navy: #0d1930;
    --navy-soft: #182743;
    --blue: #1765ff;
    --blue-dark: #0f50d2;
    --blue-soft: #eaf2ff;
    --line: #dce5f0;
    --line-strong: #c8d5e5;
    --ink: #172238;
    --muted: #687998;
    --paper: #ffffff;
    --surface: #f7f9fc;
    --bg: #f2f6fa;
    --red: #c82333;
    --red-soft: #fff0f2;
    --green: #07835d;
    --green-soft: #e9fbf3;
    --amber: #b86600;
    --amber-soft: #fff7df;
    --shadow: 0 2px 8px rgba(20, 42, 78, .06);
    --shadow-raised: 0 10px 28px rgba(20, 42, 78, .10);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 15px; line-height: 1.45; }
button, input, select, textarea { font: inherit; }
button, a, summary, input, select, textarea { outline-color: var(--blue); }
.shell { width: min(1540px, 92%); margin-inline: auto; }
.ui-icon { display: inline-block; flex: 0 0 auto; }

.system-strip { min-height: 38px; color: #b8c5d9; background: var(--navy); }
.system-strip-inner { min-height: 38px; display: flex; align-items: center; gap: 16px; font-size: 12px; }
.connection-state { display: flex; align-items: center; gap: 7px; padding-right: 16px; border-right: 1px solid #31415d; }
.connection-state > span { color: #d7e0ee; font-weight: 700; }
.connection-state strong { display: flex; align-items: center; gap: 6px; }
.connection-state strong i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px rgba(255,255,255,.05); }
.connection-state.connected strong { color: #30d49b; }
.connection-state.attention strong { color: #ffbf47; }
.system-strip form { margin: 0; }
.strip-action { display: inline-flex; align-items: center; gap: 7px; padding: 5px 0; border: 0; color: #b8c5d9; background: transparent; cursor: pointer; font-weight: 650; }
.strip-action:hover { color: #fff; }
.sync-time { margin-left: auto; color: #8292ac; }

.app-header { background: var(--paper); border-bottom: 1px solid var(--line); }
.app-header-inner { min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { min-width: 0; display: flex; align-items: center; gap: 13px; color: var(--ink); text-decoration: none; }
.brand img { width: 48px; height: 48px; object-fit: contain; }
.brand-mark { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 8px; color: #fff; background: var(--blue); box-shadow: 0 4px 10px rgba(23,101,255,.2); font-size: 15px; font-weight: 850; }
.brand-mark.large { width: 54px; height: 54px; font-size: 17px; }
.brand-copy { min-width: 0; display: grid; gap: 2px; }
.brand-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 20px; letter-spacing: 0; }
.brand-copy small { color: var(--muted); font-size: 12px; font-weight: 550; }
.account-area { display: flex; align-items: center; gap: 10px; }
.header-install { min-height: 40px; height: 40px; padding: 8px 11px; }
.pwa-install[hidden] { display: none !important; }
.account-card { min-width: 230px; display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfe; }
.account-avatar { width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 7px; color: #6b35b5; background: #f0e9ff; font-weight: 850; }
.account-card > span:last-child { min-width: 0; display: grid; gap: 1px; }
.account-card strong, .account-card small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-card strong { font-size: 13px; }
.account-card small { color: var(--muted); font-size: 11px; }
.account-area form { margin: 0; }
.icon-button { width: 40px; height: 40px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); background: var(--paper); cursor: pointer; }
.icon-button:hover { color: var(--red); border-color: #f2bcc2; background: var(--red-soft); }
.notification-button { position: relative; color: var(--muted); text-decoration: none; }
.notification-button:hover { color: var(--blue); border-color: #b9d1ff; background: var(--blue-soft); }
.notification-badge { min-width: 18px; height: 18px; display: grid; place-items: center; position: absolute; top: -7px; right: -7px; padding: 0 5px; border: 2px solid #fff; border-radius: 9px; color: #fff; background: var(--red); font-size: 9px; font-weight: 850; }
.notification-badge[hidden] { display: none; }

.module-nav-shell { position: sticky; top: 0; z-index: 10; background: rgba(255,255,255,.98); border-bottom: 1px solid var(--line); box-shadow: 0 2px 6px rgba(20,42,78,.03); }
.module-nav { min-height: 58px; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; overflow: visible; }
.module-nav a, .module-nav summary { min-height: 40px; display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto; padding: 9px 12px; border-radius: 7px; color: #52627d; text-decoration: none; font-size: 13px; font-weight: 750; white-space: nowrap; }
.module-nav a:hover { color: var(--blue); background: #f3f7ff; }
.module-nav a.active { color: #fff; background: var(--blue); box-shadow: 0 4px 10px rgba(23,101,255,.18); }
.nav-menu { position: relative; flex: 0 0 auto; }
.nav-menu summary { cursor: pointer; list-style: none; }
.nav-menu summary::-webkit-details-marker { display: none; }
.nav-menu summary:hover { color: var(--blue); background: #f3f7ff; }
.nav-menu summary.active { color: var(--blue); background: var(--blue-soft); }
.nav-submenu { min-width: 220px; display: none; position: absolute; top: calc(100% + 7px); left: 0; z-index: 30; padding: 7px; border: 1px solid var(--line); border-radius: 7px; background: #fff; box-shadow: var(--shadow-raised); }
.nav-menu[open] .nav-submenu { display: grid; }
.nav-submenu a { min-height: 38px; width: 100%; justify-content: flex-start; padding: 8px 10px; font-size: 12px; }
.nav-submenu a + a { border-top: 1px solid #edf1f6; }
.nav-submenu a.active { color: var(--blue); background: var(--blue-soft); box-shadow: none; }

.page { margin-top: 32px; margin-bottom: 64px; }
.page-heading { min-height: 66px; display: flex; align-items: flex-end; justify-content: space-between; gap: 22px; margin-bottom: 22px; }
.page-heading h1, .hero h1 { margin: 0; font-size: 29px; line-height: 1.15; letter-spacing: 0; }
.page-heading p:not(.eyebrow) { max-width: 760px; margin: 7px 0 0; color: var(--muted); }
.eyebrow { margin: 0 0 7px; color: var(--blue); font-size: 11px; font-weight: 850; letter-spacing: 0; text-transform: uppercase; }
.hero { min-height: 178px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 30px 34px; color: #fff; background: var(--navy); border: 1px solid #1b2c4d; border-radius: 8px; box-shadow: var(--shadow-raised); }
.hero-copy { max-width: 720px; }
.hero .eyebrow { color: #8bb6ff; }
.hero p:not(.eyebrow) { max-width: 680px; margin: 10px 0 0; color: #c3cee0; }
.hero-actions { display: flex; gap: 10px; }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin: 20px 0; }
.metrics article, .metrics .metric-card { min-height: 142px; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; padding: 21px; border: 1px solid var(--line); border-top: 3px solid var(--blue); border-radius: 8px; color: var(--ink); background: var(--paper); box-shadow: var(--shadow); text-align: center; text-decoration: none; }
.metrics article::before, .metrics .metric-card::before { content: ""; width: 9px; height: 9px; position: absolute; top: 16px; right: 16px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 5px var(--blue-soft); }
.metrics article:nth-child(2), .metrics .metric-card:nth-child(2) { border-top-color: #d98200; }
.metrics article:nth-child(2)::before, .metrics .metric-card:nth-child(2)::before { background: #d98200; box-shadow: 0 0 0 5px var(--amber-soft); }
.metrics article:nth-child(3), .metrics .metric-card:nth-child(3) { border-top-color: var(--red); }
.metrics article:nth-child(3)::before, .metrics .metric-card:nth-child(3)::before { background: var(--red); box-shadow: 0 0 0 5px var(--red-soft); }
.metrics article:nth-child(4), .metrics .metric-card:nth-child(4) { border-top-color: var(--green); }
.metrics article:nth-child(4)::before, .metrics .metric-card:nth-child(4)::before { background: var(--green); box-shadow: 0 0 0 5px var(--green-soft); }
.metrics span { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: 0; text-transform: uppercase; }
.metrics strong { display: block; margin-top: 9px; font-size: 30px; line-height: 1; }
.metrics .metric-card { transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease; }
.metrics .metric-card:hover { border-color: #9dbdf8; box-shadow: 0 9px 22px rgba(23,101,255,.10); transform: translateY(-2px); }

.panel { padding: 23px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); box-shadow: var(--shadow); }
.panel + .panel { margin-top: 18px; }
.panel h2 { margin: 0 0 16px; font-size: 19px; line-height: 1.25; }
.panel p { color: var(--muted); }
.panel a:not(.button) { color: var(--blue); font-weight: 750; }
.two-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.two-columns > .panel + .panel { margin-top: 0; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.section-heading h2 { margin-bottom: 4px; }
.section-heading p { margin: 0; }
.muted-text { color: var(--muted); font-weight: 500; }

.button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border: 1px solid transparent; border-radius: 7px; color: #fff; background: var(--blue); box-shadow: 0 3px 8px rgba(23,101,255,.16); cursor: pointer; text-decoration: none; font-size: 13px; font-weight: 800; }
.button:hover { background: var(--blue-dark); }
.button.muted { background: var(--navy); box-shadow: none; }
.button.secondary { color: var(--blue); background: var(--blue-soft); border-color: #cfe0ff; box-shadow: none; }
.button.secondary:hover { background: #dce9ff; }
.button.danger, .danger { background: var(--red); }
.button.full { width: 100%; margin-top: 5px; }

.notice { min-height: 48px; display: flex; align-items: center; gap: 10px; padding: 12px 15px; margin-bottom: 18px; border: 1px solid; border-radius: 7px; font-weight: 650; }
.notice.success { color: var(--green); background: var(--green-soft); border-color: #a3e5cd; }
.notice.error { color: var(--red); background: var(--red-soft); border-color: #f3b9c0; }

.panel form { display: grid; gap: 15px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
label { display: grid; gap: 7px; color: #35435a; font-size: 13px; font-weight: 750; }
input, select, textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--ink); background: #fff; padding: 10px 11px; transition: border-color .15s ease, box-shadow .15s ease; }
input, select { height: 42px; }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #74a5ff; box-shadow: 0 0 0 3px rgba(23,101,255,.11); }
input[readonly], input:disabled, select:disabled { color: #7c8ca5; background: #f2f5f9; cursor: not-allowed; }
input[type="checkbox"] { accent-color: var(--blue); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 550; }
.check input { width: auto; height: auto; }
.wide { grid-column: 1 / -1; }
.file-field small, .update-main small { color: var(--muted); font-weight: 500; }
.logo-preview { max-width: 220px; max-height: 84px; object-fit: contain; justify-self: start; }

.table-panel { padding: 0; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 13px 15px; border-bottom: 1px solid #e7edf5; text-align: left; vertical-align: middle; }
th { color: #5f708b; background: #f7f9fc; font-size: 10px; font-weight: 850; letter-spacing: 0; text-transform: uppercase; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfdff; }
td small { display: block; margin-top: 3px; color: var(--muted); }
.empty, .empty-state { padding: 42px 24px; color: var(--muted); text-align: center; }
.no-stock { color: #901d28; background: #fff6f7; }
.out { color: var(--red); font-weight: 800; }

.status { display: inline-flex; align-items: center; width: max-content; padding: 5px 8px; border-radius: 5px; color: #8a5700; background: var(--amber-soft); font-size: 11px; font-weight: 800; white-space: nowrap; }
.status.installed { color: var(--green); background: var(--green-soft); }
.status.failed { color: var(--red); background: var(--red-soft); }
.status.available { color: var(--blue); background: var(--blue-soft); }
.stat-card { min-width: 180px; padding: 14px 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); box-shadow: var(--shadow); text-align: center; }
.stat-card span { display: block; color: var(--muted); font-size: 10px; font-weight: 850; letter-spacing: 0; text-transform: uppercase; }
.stat-card strong { display: block; margin-top: 4px; font-size: 23px; }

.integration-panel { display: flex; align-items: center; justify-content: space-between; gap: 22px; }
.integration-copy { display: flex; align-items: center; gap: 14px; }
.integration-icon { width: 44px; height: 44px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 7px; color: var(--blue); background: var(--blue-soft); }
.integration-copy h2 { margin-bottom: 4px; }
.integration-copy p { margin: 0; }
.section-icon { width: 40px; height: 40px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 7px; color: var(--blue); background: var(--blue-soft); }
.settings-panel .section-heading { align-items: flex-start; padding-bottom: 17px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.settings-panel .section-heading h2 { margin-bottom: 4px; }
.settings-panel .section-heading p { margin: 0; font-size: 13px; }
.catalog-order-panel { margin-top: 20px; }
.catalog-order-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.catalog-order-item { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 58px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: grab; }
.catalog-order-item.is-dragging { opacity: .45; border-color: var(--blue); }
.catalog-order-handle { display: grid; place-items: center; color: var(--muted); }
.catalog-order-controls { display: flex; gap: 7px; }
.catalog-order-controls .button { min-height: 34px; padding: 7px 10px; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 26px; background: #edf3f9; }
.login-shell { width: min(900px, 100%); min-height: 520px; display: grid; grid-template-columns: .9fr 1.1fr; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); box-shadow: var(--shadow-raised); }
.login-intro { display: flex; flex-direction: column; justify-content: space-between; padding: 42px; color: #fff; background: var(--navy); }
.login-intro h1 { margin: 20px 0 10px; font-size: 31px; line-height: 1.15; }
.login-intro p { color: #bdc9dc; }
.login-intro small { color: #8292ac; }
.login-logo { width: 76px; height: 76px; padding: 7px; object-fit: contain; border-radius: 8px; background: #fff; }
.login-card { display: flex; flex-direction: column; justify-content: center; padding: 54px; }
.login-card h2 { margin: 0 0 7px; font-size: 25px; }
.login-card > p { margin: 0 0 27px; color: var(--muted); }
.login-card form { display: grid; gap: 16px; }
.error-text { color: var(--red); }

.update-upload-panel { margin-bottom: 20px; }
.update-upload-panel form { margin-top: 18px; }
.update-row { display: flex; align-items: center; justify-content: space-between; gap: 22px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.update-row:last-child { border-bottom: 0; }
.update-main { min-width: 0; }
.update-title { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; font-size: 14px; }
.update-title strong { font-size: 19px; }
.update-main p { margin: 8px 0; }
.success-label { color: var(--green); font-size: 12px; font-weight: 800; }
.error-label { max-width: 360px; color: var(--red); font-size: 12px; }
.push-panel { margin-bottom: 18px; }
.push-panel .section-heading { align-items: center; }
.push-panel .section-heading h2 { margin-bottom: 4px; }
.push-panel .section-heading p { margin: 0; }
.ios-push-help { margin: 17px 0 0; color: #725500; background: #fff8d8; border-color: #f3dc70; }
.ios-push-help[hidden] { display: none; }
.notification-list { padding: 0; overflow: hidden; }
.notification-row { margin: 0; border-bottom: 1px solid var(--line); }
.notification-row:last-child { border-bottom: 0; }
.notification-row button { width: 100%; display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 16px 19px; border: 0; color: inherit; background: #fff; cursor: pointer; text-align: left; }
.notification-row button:hover { background: #f8fbff; }
.notification-row.unread button { background: #f4f8ff; }
.notification-dot { width: 8px; height: 8px; border-radius: 50%; background: #c9d3e1; }
.notification-row.unread .notification-dot { background: var(--blue); box-shadow: 0 0 0 4px var(--blue-soft); }
.notification-copy { min-width: 0; display: grid; gap: 3px; }
.notification-copy strong { font-size: 14px; }
.notification-copy span { color: #52627d; font-size: 13px; }
.notification-copy small { color: var(--muted); font-size: 11px; }
.notification-open { color: var(--blue); font-size: 12px; font-weight: 800; }
.order-actions { display: flex; justify-content: flex-end; margin-top: 16px; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 16px 18px; border-top: 1px solid var(--line); }
.pagination-summary { margin: 0; color: var(--muted); font-size: 12px; }
.pagination-links { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.pagination-link { min-width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; padding: 0 9px; border: 1px solid var(--line); border-radius: 6px; color: #52627d; background: #fff; text-decoration: none; font-size: 12px; font-weight: 750; }
.pagination-link:hover { color: var(--blue); border-color: #a9c7ff; background: var(--blue-soft); }
.pagination-link.current { color: #fff; border-color: var(--blue); background: var(--blue); }
.pagination-link.disabled { color: #9aa8bb; background: #f4f6f9; cursor: not-allowed; }

@media (max-width: 1100px) {
    .shell { width: 94%; }
    .brand-copy small, .sync-time { display: none; }
    .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    .system-strip-inner { justify-content: space-between; }
    .connection-state { border-right: 0; padding-right: 0; }
    .app-header-inner { min-height: 70px; }
    .brand-copy strong { max-width: 190px; font-size: 16px; }
    .brand img, .brand-mark { width: 40px; height: 40px; }
    .account-card { min-width: 0; padding: 7px; }
    .account-card > span:last-child { display: none; }
    .header-install span { display: none; }
    .header-install { width: 40px; padding: 0; }
    .module-nav { min-height: 54px; }
    .page { margin-top: 22px; }
    .page-heading, .hero, .integration-panel { align-items: flex-start; flex-direction: column; }
    .page-heading h1, .hero h1 { font-size: 25px; }
    .hero { min-height: 0; padding: 25px; }
    .two-columns, .form-grid { grid-template-columns: 1fr; }
    .catalog-order-item { grid-template-columns: 30px minmax(0, 1fr); }
    .catalog-order-controls { grid-column: 2; }
    .wide { grid-column: auto; }
    .login-shell { min-height: 0; grid-template-columns: 1fr; }
    .login-intro { padding: 28px; }
    .login-intro small { display: none; }
    .login-card { padding: 34px 28px; }
    .update-row { align-items: flex-start; flex-direction: column; }
    .push-panel .section-heading { align-items: stretch; flex-direction: column; }
    .push-panel .button { width: 100%; }
    .notification-row button { grid-template-columns: 10px minmax(0, 1fr); }
    .notification-open { display: none; }
    .pagination { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 520px) {
    .shell { width: 94%; }
    .system-strip-inner { gap: 8px; }
    .connection-state > span { display: none; }
    .strip-action { font-size: 0; }
    .strip-action .ui-icon { width: 17px; height: 17px; }
    .metrics { grid-template-columns: 1fr 1fr; gap: 10px; }
    .metrics article, .metrics .metric-card { min-height: 120px; padding: 17px 12px; }
    .metrics strong { font-size: 26px; }
    .panel { padding: 18px; }
    .stat-card { width: 100%; }
    .hero-actions { width: 100%; }
    .hero-actions .button { flex: 1; }
}
