:root {
  --ink: #17213a;
  --muted: #69738a;
  --line: #e4e8f0;
  --surface: #ffffff;
  --canvas: #f4f6fa;
  --brand: #3157e3;
  --brand-dark: #2445be;
  --success: #16794d;
  --success-bg: #e8f6ef;
  --warning: #9b6412;
  --warning-bg: #fff4dc;
  --danger: #b42318;
  --shadow: 0 18px 45px rgba(24, 34, 58, .12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 .4rem; color: var(--brand); font-size: .72rem; font-weight: 800; letter-spacing: .12em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 2rem; background: radial-gradient(circle at 15% 10%, #dfe7ff, transparent 35%), linear-gradient(145deg, #f7f9ff, #eef1f8); }
.login-card { width: min(430px, 100%); padding: 2.6rem; border: 1px solid rgba(255,255,255,.7); border-radius: 24px; background: rgba(255,255,255,.9); box-shadow: var(--shadow); backdrop-filter: blur(14px); }
.login-card h1 { margin: .25rem 0 .4rem; font-size: 2rem; }
.login-card form { display: grid; gap: 1rem; margin-top: 1.8rem; }
.brand-mark { display: grid; width: 54px; height: 54px; place-items: center; border-radius: 16px; color: white; background: linear-gradient(135deg, #335be8, #713de0); font-size: 1.2rem; font-weight: 850; box-shadow: 0 10px 24px rgba(49,87,227,.25); }
.brand-mark.small { width: 38px; height: 38px; border-radius: 12px; font-size: .9rem; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 5; display: flex; width: 245px; flex-direction: column; padding: 1.5rem 1rem; color: white; background: #151e35; }
.brand { display: flex; align-items: center; gap: .75rem; padding: 0 .5rem 1.8rem; font-weight: 850; letter-spacing: .06em; }
.sidebar nav { display: grid; gap: .35rem; }
.nav-item { display: flex; width: 100%; justify-content: space-between; padding: .85rem 1rem; border: 0; border-radius: 11px; color: #cad2e5; background: transparent; text-align: left; text-decoration: none; font-weight: 650; }
.nav-item.active { color: white; background: rgba(255,255,255,.1); }
.nav-item.disabled { opacity: .62; cursor: default; }
.nav-item small { font-size: .62rem; font-weight: 500; }
.sidebar-footer { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding: 1rem .6rem 0; border-top: 1px solid rgba(255,255,255,.12); color: #cad2e5; font-size: .85rem; }
.text-button { border: 0; color: #fff; background: transparent; }
main { min-height: 100vh; margin-left: 245px; padding: 2.1rem clamp(1.5rem, 4vw, 4rem); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.topbar h1 { margin: 0; font-size: clamp(1.7rem, 3vw, 2.35rem); }
.topbar-actions { display: flex; gap: .7rem; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin: 2rem 0; }
.metrics article { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.4rem; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.metrics span { color: var(--muted); font-size: .88rem; font-weight: 650; }
.metrics strong { font-size: 1.7rem; }
.content-section { padding: 1.5rem; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.section-heading h2 { margin: 0 0 .3rem; }
.section-heading p { margin: 0; }
.search input { width: min(300px, 38vw); }
.structure-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1rem; }
.structure-card { display: flex; min-height: 230px; flex-direction: column; padding: 1.25rem; border: 1px solid var(--line); border-radius: 16px; background: #fff; transition: transform .18s, box-shadow .18s; }
.structure-card:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(24,34,58,.08); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.card-head h3 { margin: 0; font-size: 1.08rem; }
.card-head p { margin: .25rem 0 0; color: var(--muted); font-size: .85rem; }
.badge { display: inline-flex; padding: .32rem .55rem; border-radius: 999px; font-size: .7rem; font-weight: 800; }
.badge.active { color: var(--success); background: var(--success-bg); }
.badge.suspended { color: var(--warning); background: var(--warning-bg); }
.greeting-preview { margin: 1.2rem 0; color: #46516a; font-size: .87rem; line-height: 1.5; }
.phone-list { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: auto; }
.phone-chip { padding: .36rem .55rem; border: 1px solid var(--line); border-radius: 8px; color: #45516a; background: #f8f9fc; font-size: .76rem; }
.card-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
.user-grid { display: grid; gap: .75rem; }
.user-card { display: grid; grid-template-columns: minmax(180px, 1.2fr) minmax(180px, 1fr) auto auto; align-items: center; gap: 1rem; padding: 1rem 1.15rem; border: 1px solid var(--line); border-radius: 13px; }
.user-card h3, .user-card p { margin: 0; }
.user-card h3 { font-size: .98rem; }
.user-card p, .user-card small { color: var(--muted); }
.user-role { font-size: .78rem; font-weight: 750; }
.operations-heading > label { min-width: min(320px, 100%); }
.operations-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.management-panel { padding: 1.2rem; border: 1px solid var(--line); border-radius: 16px; background: #fbfcff; }
.management-panel h3 { margin: 0; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.management-list { display: grid; gap: .65rem; }
.management-item { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 1rem; padding: .9rem; border: 1px solid var(--line); border-radius: 11px; background: white; }
.management-item h4, .management-item p { margin: 0; }
.management-item h4 { font-size: .95rem; }
.management-item p { margin-top: .25rem; color: var(--muted); font-size: .8rem; line-height: 1.4; }
.management-meta { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .5rem; }
.meta-chip { padding: .25rem .45rem; border-radius: 6px; color: #46516a; background: #eef1f7; font-size: .7rem; font-weight: 700; }
.empty-state.compact { padding: 1.5rem .5rem; }
.hours-panel { margin-top: 1rem; }
.weekly-hours { display: grid; gap: .55rem; }
.hours-row { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(120px, .7fr) minmax(120px, .7fr); align-items: center; gap: .8rem; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: 10px; background: white; }
.day-toggle { display: flex; align-items: center; gap: .65rem; font-size: .86rem; }
.day-toggle input { width: auto; }
.panel-footer { display: flex; justify-content: flex-end; margin-top: 1rem; }

.button { min-height: 42px; padding: .68rem 1rem; border: 0; border-radius: 10px; font-weight: 750; }
.button.primary { color: white; background: var(--brand); box-shadow: 0 8px 18px rgba(49,87,227,.2); }
.button.primary:hover { background: var(--brand-dark); }
.button.secondary { color: var(--ink); background: #eef1f7; }
.button.full { width: 100%; }
.button:disabled { opacity: .55; cursor: wait; }
.icon-button { width: 38px; height: 38px; border: 0; border-radius: 50%; color: var(--muted); background: #f0f2f7; font-size: 1.45rem; }
label { display: grid; gap: .42rem; color: #3b465d; font-size: .82rem; font-weight: 700; }
input, select, textarea { width: 100%; padding: .74rem .8rem; border: 1px solid #ccd3e0; border-radius: 9px; color: var(--ink); background: white; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(49,87,227,.12); }
textarea { resize: vertical; line-height: 1.45; }
.form-error { min-height: 1.2rem; margin: .3rem 0; color: var(--danger); font-size: .82rem; }
.notice { margin-bottom: 1rem; padding: .8rem 1rem; border-radius: 10px; color: var(--success); background: var(--success-bg); }
.notice.error { color: var(--danger); background: #fff0ef; }
.empty-state { padding: 4rem 1rem; text-align: center; color: var(--muted); }
.empty-state h3 { color: var(--ink); }

dialog { width: min(760px, calc(100% - 2rem)); max-height: calc(100vh - 2rem); padding: 0; border: 0; border-radius: 20px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(16,24,42,.58); backdrop-filter: blur(3px); }
#structure-form { padding: 1.5rem; }
#user-form, #password-form, #service-form, #operator-form, #customer-form, #appointment-form { max-height: calc(100vh - 2rem); overflow-y: auto; padding: 1.5rem; }
.dialog-header, .dialog-footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.dialog-header { margin-bottom: 1.4rem; }
.dialog-header h2 { margin: 0; }
.dialog-footer { justify-content: flex-end; padding-top: 1rem; border-top: 1px solid var(--line); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 1rem; }
.form-grid .wide { grid-column: 1 / -1; }
.phone-editor { margin: 1.3rem 0; padding: 1rem; border: 1px solid var(--line); border-radius: 12px; background: #f9fafc; }
.phone-editor h3, .phone-editor p { margin: 0 0 .25rem; }
.phone-add-row { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; margin-top: .8rem; }
.phone-edit-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .7rem; margin-top: .6rem; padding: .65rem; border-radius: 9px; background: white; }
.phone-edit-row p { margin: 0; color: var(--ink); font-weight: 650; }
.phone-edit-row small { color: var(--muted); }
.password-note { margin: 1rem 0 0; font-size: .82rem; }
.password-fields { display: grid; gap: 1rem; margin: 1.25rem 0; }
.heading-controls { display: flex; align-items: end; gap: .7rem; flex-wrap: wrap; }
.heading-controls label { min-width: 145px; }
.heading-controls .search { min-width: 250px; }
.customer-list, .appointment-list { display: grid; gap: .7rem; }
.customer-item, .appointment-item { display: grid; grid-template-columns: minmax(180px, 1.2fr) minmax(170px, 1fr) minmax(150px, .8fr) auto; align-items: center; gap: 1rem; padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: 13px; background: white; }
.customer-item h3, .customer-item p, .appointment-item h3, .appointment-item p { margin: 0; }
.customer-item p, .appointment-item p { margin-top: .25rem; color: var(--muted); font-size: .8rem; }
.appointment-time { font-weight: 800; }
.appointment-status { justify-self: start; }
.badge.cancelled, .badge.archived { color: var(--muted); background: #eef1f7; }
.badge.confirmed, .badge.completed { color: var(--success); background: var(--success-bg); }
.badge.scheduled { color: var(--brand); background: #eaf0ff; }
.badge.no_show { color: var(--warning); background: var(--warning-bg); }

@media (max-width: 780px) {
  .sidebar { position: static; width: auto; min-height: auto; padding: 1rem; }
  .sidebar nav { display: flex; gap: .35rem; overflow-x: auto; padding-bottom: .2rem; }
  .nav-item { width: auto; flex: 0 0 auto; }
  .nav-item.disabled { display: none; }
  .sidebar-footer { margin-top: .75rem; padding-top: .75rem; }
  main { margin-left: 0; padding: 1.25rem; }
  .metrics { grid-template-columns: 1fr; }
  .section-heading, .topbar { align-items: stretch; flex-direction: column; }
  .topbar-actions { flex-direction: column; }
  .search input { width: 100%; }
  .form-grid, .phone-add-row { grid-template-columns: 1fr; }
  .user-card { grid-template-columns: 1fr; }
  .operations-grid { grid-template-columns: 1fr; }
  .hours-row { grid-template-columns: 1fr 1fr; }
  .hours-row .day-toggle { grid-column: 1 / -1; }
  .panel-heading { align-items: stretch; flex-direction: column; }
  .heading-controls { align-items: stretch; flex-direction: column; }
  .heading-controls label, .heading-controls .search { min-width: 0; }
  .customer-item, .appointment-item { grid-template-columns: 1fr; }
}
