/* Admin panel & login */
.login-wrap { min-height: 100vh; display: flex; flex-wrap: wrap; }
.login-brand { flex: 1 1 480px; min-width: 0; background: var(--accent); color: #FFFFFF; position: relative; overflow: hidden; padding: clamp(32px, 5vw, 64px); display: flex; flex-direction: column; justify-content: space-between; gap: 48px; min-height: 320px; }
.login-brand h1 { font-size: clamp(2rem, 3.6vw, 3rem); letter-spacing: -0.03em; max-width: 14ch; margin-bottom: 16px; }
.login-brand .brand, .login-brand .brand-name span { color: #FFFFFF; }
.login-side { flex: 1 1 480px; min-width: 0; display: flex; align-items: center; justify-content: center; padding: clamp(32px, 5vw, 64px) 24px; }
.login-box { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 18px; }
.login-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.pass-wrap { position: relative; }
.pass-wrap input { padding-right: 76px; }
.pass-wrap button { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); height: 40px; padding: 0 12px; border: 0; background: transparent; color: var(--link); font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; }
.note { font-size: 14px; background: var(--surface-2); border-radius: 12px; padding: 12px 14px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.admin { display: flex; flex-wrap: wrap; min-height: 100vh; }
.sidebar { flex: 1 1 250px; min-width: 0; background: var(--surface); border-right: 1px solid var(--line); padding: 22px 16px; display: flex; flex-direction: column; gap: 24px; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.side-link { font: inherit; font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px 14px; min-height: 44px; border-radius: 12px; border: 0; cursor: pointer; background: transparent; color: var(--muted); text-decoration: none; }
.side-link svg { width: 20px; height: 20px; flex: none; }
.side-link[aria-current="page"] { background: var(--surface-2); color: var(--text); }
.side-link .badge { margin-left: auto; font-size: 12px; font-weight: 700; background: var(--accent); color: #FFFFFF; border-radius: 999px; padding: 2px 8px; }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 16px; display: flex; flex-direction: column; gap: 4px; }
.side-foot .logout { color: var(--bad); }
.admin-main { flex: 999 1 560px; min-width: 0; padding: 24px clamp(18px, 3vw, 40px) 48px; }
.admin-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.admin-top h1 { font-size: 1.8rem; letter-spacing: -0.02em; }
.admin-top .tools { display: flex; align-items: center; gap: 12px; }
.avatar { width: 44px; height: 44px; border-radius: 999px; background: var(--accent); color: #FFFFFF; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.view[hidden] { display: none; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; }
.panel-pad { padding: 24px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat p:first-child { font-size: 14px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.stat .num { font-family: var(--display); font-weight: 600; font-size: 2rem; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: 13px; color: var(--muted); margin-top: 4px; }
.row-wrap { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 20px; }
.row-wrap > * { flex: 1 1 340px; min-width: 0; }
.bar-label { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }
.bar { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-bottom: 14px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.quick { display: flex; flex-direction: column; gap: 10px; }
.quick button, .quick a { font: inherit; font-weight: 700; font-size: 15px; text-align: left; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text); cursor: pointer; text-decoration: none; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th { text-align: left; font-size: 13px; font-weight: 700; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 14px 16px; border-bottom: 1px solid var(--line); font-size: 15px; vertical-align: middle; }
td small { display: block; color: var(--muted); font-size: 13px; }
td .actions { display: flex; gap: 4px; justify-content: flex-end; }
td .actions a, td .actions button { font: inherit; font-size: 14px; font-weight: 700; color: var(--link); text-decoration: none; padding: 8px; background: none; border: 0; cursor: pointer; }
td .actions .del { color: var(--bad); }
.status { font: inherit; font-size: 14px; font-weight: 700; background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; min-height: 36px; }
.status[data-s="New"] { color: var(--link); }
.status[data-s="Contacted"] { color: var(--warn); }
.status[data-s="Closed"] { color: var(--ok); }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 16px; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filters button { font: inherit; font-size: 14px; font-weight: 700; min-height: 40px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: transparent; color: var(--text); cursor: pointer; }
.filters button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #FFFFFF; }
.toolbar input { font: inherit; font-size: 15px; color: var(--text); background: var(--bg); padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: 12px; width: 280px; max-width: 100%; }
.empty { padding: 28px 16px; color: var(--muted); text-align: center; }
.switch { width: 52px; height: 30px; border-radius: 999px; border: 0; padding: 3px; cursor: pointer; background: var(--line-strong); display: flex; justify-content: flex-start; flex: none; }
.switch[aria-checked="true"] { background: var(--accent); justify-content: flex-end; }
.switch span { width: 24px; height: 24px; border-radius: 999px; background: #FFFFFF; }
.product-card { display: flex; flex-direction: column; gap: 10px; padding: 24px; }
.product-card header { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.ok-text { color: var(--ok); font-weight: 700; font-size: 14px; }
.off-text { color: var(--muted); font-weight: 700; font-size: 14px; }
.preview { background: var(--bg); border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: flex; gap: 14px; box-shadow: 0 10px 30px rgba(5,10,30,.18); }
.preview p { overflow-wrap: anywhere; }
.form-grid { display: flex; flex-direction: column; gap: 16px; }

/* Quotations */
.q-fieldset { border: 1px solid var(--line); border-radius: 16px; padding: 18px; margin: 0; display: flex; flex-direction: column; gap: 16px; }
.q-fieldset legend { font-weight: 700; padding: 0 8px; }
.q-items { min-width: 760px; }
.q-items td { padding: 8px; }
.q-items input { font: inherit; font-size: 15px; color: var(--text); background: var(--bg); padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px; width: 100%; }
.q-items input[type="number"] { min-width: 80px; }
.q-items .amt { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.q-items .rm { font: inherit; font-size: 14px; font-weight: 700; color: var(--bad); background: none; border: 0; cursor: pointer; padding: 10px; }
.q-totals { display: flex; flex-direction: column; gap: 10px; }
.q-totals > div { display: flex; justify-content: space-between; gap: 12px; font-variant-numeric: tabular-nums; }
.q-totals > div[hidden] { display: none; }
.q-totals .grand { border-top: 1px solid var(--line); padding-top: 12px; font-size: 1.2rem; }
.q-totals .grand strong { color: var(--hi); font-family: var(--display); }
.q-badge { font-size: 13px; font-weight: 700; border-radius: 999px; padding: 4px 10px; background: var(--surface-2); }
.q-badge[data-s="Accepted"] { color: var(--ok); }
.q-badge[data-s="Rejected"] { color: var(--bad); }
.q-badge[data-s="Sent"] { color: var(--link); }

/* Sales report */
.sales-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.sales-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sales .stats { margin-bottom: 0; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.sales .stat { background: var(--bg); }
.sales-chart { display: flex; align-items: flex-end; gap: 8px; height: 220px; padding: 8px 4px 0; border-bottom: 1px solid var(--line-strong); }
.sales-chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; gap: 6px; }
.sales-chart .val { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sales-chart .bar-v { width: 100%; max-width: 44px; background: var(--accent); border-radius: 6px 6px 0 0; min-height: 2px; }
.sales-chart .col.current .bar-v { background: var(--hi); }
.chart-labels { display: flex; gap: 8px; padding: 6px 4px 0; }
.chart-labels span { flex: 1; text-align: center; font-size: 12px; color: var(--muted); min-width: 0; }
.sample-tag { font-size: 12px; font-weight: 700; color: var(--warn); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; margin-left: 6px; }
.trend-up { color: var(--ok); font-weight: 700; }
.trend-down { color: var(--bad); font-weight: 700; }

/* Follow-ups */
.stage { font-size: 13px; font-weight: 700; border-radius: 999px; padding: 4px 10px; background: var(--surface-2); white-space: nowrap; }
.stage[data-s="Sent"] { color: var(--link); }
.stage[data-s="Negotiation"] { color: var(--warn); }
.stage[data-s="Accepted"] { color: var(--ok); }
.stage[data-s="Rejected"] { color: var(--bad); }
.due { font-weight: 700; white-space: nowrap; }
.due.overdue { color: var(--bad); }
.due.today { color: var(--warn); }
.due.later { color: var(--muted); font-weight: 600; }
tr.selected td { background: var(--surface-2); }
.quick-dates { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.quick-dates button { font: inherit; font-size: 13px; font-weight: 700; min-height: 36px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: transparent; color: var(--text); cursor: pointer; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0; max-height: 420px; overflow-y: auto; }
.timeline li { position: relative; padding: 0 0 18px 26px; border-left: 2px solid var(--line); margin-left: 7px; }
.timeline li:last-child { border-left-color: transparent; }
.timeline li::before { content: ""; position: absolute; left: -8px; top: 2px; width: 14px; height: 14px; border-radius: 999px; background: var(--accent); border: 3px solid var(--surface); }
.timeline .when { font-size: 13px; color: var(--muted); }
.timeline .what { font-weight: 700; }
.timeline p { font-size: 15px; margin-top: 2px; }
.fu-dash-item { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.fu-dash-item button { font: inherit; font-weight: 700; color: var(--text); background: none; border: 0; cursor: pointer; text-align: left; padding: 0; }

#fuStages { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

/* Billing */
.pay-badge { font-size: 13px; font-weight: 700; border-radius: 999px; padding: 4px 10px; background: var(--surface-2); white-space: nowrap; }
.pay-badge[data-s="Paid"] { color: var(--ok); }
.pay-badge[data-s="Partially paid"] { color: var(--warn); }
.pay-badge[data-s="Unpaid"] { color: var(--link); }
.pay-badge[data-s="Overdue"] { color: var(--bad); }
#billStats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

#venStats { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
[role="tab"][aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: #FFFFFF; }
#venStats .num, #billStats .num { font-size: 1.3rem !important; }

/* Customers */
#cuStats, #cpStats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
#cuStats .num, #cpStats .num { font-size: 1.3rem !important; }
.cp-dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; font-size: 15px; }
.cp-dl dt { color: var(--muted); font-weight: 600; }
.cp-dl dd { margin: 0; overflow-wrap: anywhere; }
.tag { display: inline-block; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 3px 10px; margin: 0 4px 4px 0; background: var(--surface-2); color: var(--link); }

.bill-kinds button[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: #FFFFFF; }
.kind-tag { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 2px 8px; margin-left: 6px; background: var(--surface-2); }
.kind-tag[data-k="product"] { color: var(--link); }
.kind-tag[data-k="service"] { color: var(--ok); }
.kind-tag[data-k="amc"] { color: var(--hi); }

/* Users, roles, permissions */
.user-menu { position: relative; }
button.avatar { border: 0; cursor: pointer; font: inherit; font-weight: 700; }
.user-panel { position: absolute; right: 0; top: calc(100% + 8px); width: min(320px, calc(100vw - 32px)); z-index: 30; box-shadow: var(--shadow); }
.role-badge { font-size: 13px; font-weight: 700; border-radius: 999px; padding: 4px 10px; background: var(--surface-2); color: var(--link); white-space: nowrap; }
.role-badge[data-r="owner"] { color: var(--hi); }
.perm-table td, .perm-table th { text-align: center; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; font-weight: 700; }
.perm-table input { width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; }
.perm-table input:disabled { cursor: not-allowed; opacity: .5; }
.perm-na { color: var(--muted); }
.role-card { display: flex; flex-direction: column; gap: 6px; padding: 20px; }
.role-card[aria-current="true"] { border-color: var(--accent); }
.role-card .actions { display: flex; gap: 12px; }
.role-card .actions button { font: inherit; font-size: 14px; font-weight: 700; color: var(--link); background: none; border: 0; cursor: pointer; padding: 8px 0; min-height: 36px; }
.role-card .actions .del { color: var(--bad); }

/* Service tickets */
#tkStats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
#tkStats .num { font-size: 1.4rem !important; }
.prio { font-size: 13px; font-weight: 700; border-radius: 999px; padding: 4px 10px; background: var(--surface-2); white-space: nowrap; }
.prio[data-p="Urgent"] { color: var(--bad); }
.prio[data-p="High"] { color: var(--warn); }
.prio[data-p="Medium"] { color: var(--link); }
.prio[data-p="Low"] { color: var(--muted); }
.tk-status { font-size: 13px; font-weight: 700; border-radius: 999px; padding: 4px 10px; background: var(--surface-2); white-space: nowrap; }
.tk-status[data-s="Open"] { color: var(--link); }
.tk-status[data-s="Assigned"], .tk-status[data-s="In progress"] { color: var(--hi); }
.tk-status[data-s^="Waiting"] { color: var(--warn); }
.tk-status[data-s="Resolved"], .tk-status[data-s="Closed"] { color: var(--ok); }
.tk-status[data-s="Cancelled"] { color: var(--muted); }
.sla-late { color: var(--bad); font-weight: 700; }
.timeline li.public::before { background: var(--ok); }

/* Database sync */
.db-state { font-size: 13px; font-weight: 600; color: var(--ok); }
.db-state.bad { color: var(--bad); }
.db-state:empty { display: none; }
.db-banner { margin-bottom: 16px; border-left: 4px solid var(--accent); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.db-banner[hidden] { display: none; }
