/* Yonderly Admin — shared design system (MP072 palette).
   Single source of truth for theming. Components reference var(--token); never hardcode hex.
   See docs/redesign/design-system.md. */

:root {
  /* palette → semantic tokens */
  --canvas:         #EEE9DF; /* Palladian */
  --surface:        #FFFFFF;
  --surface-alt:    #FAF8F3;
  --surface-muted:  #C9C1B1; /* Oatmeal */
  --surface-dark:   #2C3B4D; /* Blue Fantastic */
  --surface-darkest:#1B2632; /* Abyssal */
  --accent:         #FFB162; /* Burning Flame */
  --accent-2:       #A35139; /* Truffle Trouble */
  --text:           #1B2632;
  --text-muted:     #6B7280;
  --on-dark:        #EEE9DF;
  --on-accent:      #1B2632;
  --border:         #E3DDD0;

  /* functional */
  --success-bg: #E3F0E3; --success-fg: #2F6B3A;
  --danger-bg:  #F0DDD6; --danger-fg:  #A35139;
  --warning-bg: #FBE9D2; --warning-fg: #8A5A1E;

  /* shape / elevation / type */
  --radius:      22px;
  --radius-sm:   14px;
  --radius-pill: 999px;
  --shadow:      0 18px 40px -24px rgba(27,38,50,.45);
  --shadow-sm:   0 8px 20px -16px rgba(27,38,50,.4);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--canvas); color: var(--text); -webkit-font-smoothing: antialiased; line-height: 1.45; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { letter-spacing: -.4px; font-weight: 700; margin: 0; }

/* ---- App layout shell ---- */
.layout-wrapper { display: flex; min-height: 100vh; padding: 18px; gap: 18px; }
.main-content { flex: 1; min-width: 0; }
.content { width: 100%; }

/* ---- Sidebar ---- */
.side-nav {
  width: 230px; flex-shrink: 0; background: var(--surface-dark); color: var(--on-dark);
  border-radius: var(--radius); padding: 26px 18px; display: flex; flex-direction: column;
  box-shadow: var(--shadow); position: sticky; top: 18px; align-self: flex-start;
  max-height: calc(100vh - 36px);
}
.nav-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; padding: 0 8px 22px; letter-spacing: -.4px; color: #fff; }
.nav-brand .brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; color: var(--surface-darkest); flex-shrink: 0; }
.nav-brand .brand-mark svg { width: 18px; height: 18px; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: #8ea0b3; padding: 18px 12px 8px; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; color: #c4d0dc; text-decoration: none; font-size: 14.5px; font-weight: 500; margin-bottom: 2px; transition: background .15s, color .15s; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.nav-link svg { width: 19px; height: 19px; flex-shrink: 0; }
.nav-divider { border: none; border-top: 1px solid rgba(255,255,255,.1); margin: 12px 8px; }
.nav-spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 14px; background: rgba(255,255,255,.05); }
.user-chip .av { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: var(--surface-darkest); display: grid; place-items: center; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.user-chip .meta { font-size: 13px; line-height: 1.3; min-width: 0; }
.user-chip .meta small { color: #8ea0b3; display: block; }

/* ---- Header / page head ---- */
.page-head { display: flex; align-items: center; gap: 20px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head .titles { min-width: 0; }
.page-head h1 { font-size: 27px; }
.page-head .sub, .page-sub { color: var(--text-muted); font-size: 14.5px; margin-top: 3px; }
.page-head .grow { flex: 1; }
.page-head .actions { display: flex; align-items: center; gap: 12px; }

/* ---- Search ---- */
.search { display: flex; align-items: center; gap: 9px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 11px 18px; color: var(--text-muted); box-shadow: var(--shadow-sm); }
.search svg { width: 17px; height: 17px; flex-shrink: 0; }
.search input { border: none; outline: none; background: none; font: inherit; font-size: 14px; width: 100%; color: var(--text); }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; gap: 8px; background: var(--surface-darkest); color: var(--on-dark); border: 1px solid transparent; border-radius: var(--radius-pill); padding: 11px 20px; font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; transition: filter .15s, background .15s; text-decoration: none; line-height: 1; }
.btn:hover { filter: brightness(1.15); text-decoration: none; }
.btn svg { width: 16px; height: 16px; }
.btn--accent { background: var(--accent); color: var(--on-accent); }
.btn--accent:hover { filter: none; background: #ffa24a; }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn--ghost:hover { background: var(--surface-alt); filter: none; }
.btn--danger { background: transparent; color: var(--danger-fg); border-color: var(--danger-fg); }
.btn--danger:hover { background: var(--danger-bg); filter: none; }
.btn--sm { padding: 8px 14px; font-size: 13px; }
.btn--block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---- Tabs ---- */
.tabs { display: inline-flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 5px; margin-bottom: 22px; box-shadow: var(--shadow-sm); }
.tab { display: inline-flex; align-items: center; gap: 8px; background: transparent; border: none; border-radius: var(--radius-pill); padding: 9px 18px; font: inherit; font-weight: 600; font-size: 14px; color: var(--text-muted); cursor: pointer; transition: background .15s, color .15s; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface-darkest); color: var(--on-dark); }
.tab svg { width: 16px; height: 16px; }

/* small icon-only action button (table rows) */
.btn-action { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--surface-alt); color: var(--text-muted); border: 1px solid var(--border); cursor: pointer; transition: .15s; }
.btn-action:hover { background: var(--canvas); color: var(--text); }
.btn-action.danger:hover { background: var(--danger-bg); color: var(--danger-fg); border-color: var(--danger-fg); }
.btn-action svg { width: 16px; height: 16px; }

/* "+ Add" affordance */
.add { display: inline-flex; align-items: center; gap: 8px; color: var(--accent-2); font-size: 13.5px; font-weight: 600; cursor: pointer; background: none; border: none; font-family: inherit; }
.add:hover { text-decoration: none; }
.add .plus { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; }
.add .plus svg { width: 15px; height: 15px; }

/* ---- Cards ---- */
.card { background: var(--surface); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow-sm); }
.card + .card { margin-top: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; }
.card-head h3 { font-size: 17px; display: flex; align-items: center; gap: 8px; }
.card-head h3 svg, .page-head h1 svg { width: 18px; height: 18px; flex-shrink: 0; }
.card .card-sub { color: var(--text-muted); font-size: 13px; margin: 2px 0 16px; }
.card--dark { background: var(--surface-dark); color: var(--on-dark); }
.card--dark h1, .card--dark h2, .card--dark h3 { color: #fff; }
.card--dark .card-sub { color: #9fb0c0; }

/* plan / pricing feature list */
.plan-features { list-style: none; padding: 0; margin: 10px 0 16px; font-size: 13.5px; color: var(--text-muted); }
.plan-features li { padding: 6px 0; border-bottom: 1px dashed var(--border); }
.plan-features li strong { color: var(--text); }

/* grids */
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.row-2-1 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; }

/* ---- Stat card ---- */
.stat { background: var(--surface); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm); }
.stat .ico { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; margin-bottom: 16px; background: #fff0e0; color: var(--accent-2); }
.stat .ico.alt { background: #e7edf2; color: var(--surface-dark); }
.stat .ico svg { width: 21px; height: 21px; }
.stat .num { font-size: 30px; font-weight: 700; letter-spacing: -1px; }
.stat .lbl { color: var(--text-muted); font-size: 13.5px; margin-top: 2px; }
.stat .delta { font-size: 12.5px; font-weight: 600; color: var(--accent-2); margin-top: 10px; }

/* ---- Tables ---- */
.table-wrap { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table thead th { background: var(--surface-alt); text-align: left; text-transform: uppercase; font-size: 11px; letter-spacing: .5px; color: var(--text-muted); font-weight: 700; padding: 14px 18px; }
.table tbody td { padding: 14px 18px; border-top: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: var(--surface-alt); }
.table .empty { text-align: center; color: var(--text-muted); padding: 36px; }

/* ---- Badges ---- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; padding: 5px 11px; border-radius: var(--radius-pill); background: var(--surface-muted); color: var(--surface-darkest); }
.badge--ok { background: var(--success-bg); color: var(--success-fg); }
.badge--off { background: var(--danger-bg); color: var(--danger-fg); }
.badge--warn { background: var(--warning-bg); color: var(--warning-fg); }
.badge--accent { background: #fff0e0; color: var(--accent-2); }

/* ---- Forms ---- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.input, .field input, .field select, .field textarea,
input.input, select.input, textarea.input {
  width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 11px 14px; font: inherit; font-size: 14px; color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,177,98,.3);
}
.field .hint { font-size: 12.5px; color: var(--text-muted); margin-top: 5px; }

/* ---- Inline messages ---- */
.msg { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; }
.msg.ok { background: var(--success-bg); color: var(--success-fg); }
.msg.err { background: var(--danger-bg); color: var(--danger-fg); }
.msg.warn { background: var(--warning-bg); color: var(--warning-fg); }

/* ---- Modal ---- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(27,38,50,.45); display: grid; place-items: center; z-index: 1000; padding: 20px; }
.modal-card { background: var(--surface); border-radius: var(--radius); width: 100%; max-width: 520px; box-shadow: var(--shadow); max-height: 90vh; overflow-y: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 22px 24px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 18px; }
.modal-body { padding: 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 12px; padding: 18px 24px; border-top: 1px solid var(--border); background: var(--surface-alt); border-radius: 0 0 var(--radius) var(--radius); }
.btn-close { background: none; border: none; cursor: pointer; color: var(--text-muted); display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; }
.btn-close:hover { background: var(--surface-alt); color: var(--text); }
.btn-close svg { width: 18px; height: 18px; }

/* ---- List rows (devices, activity) ---- */
.list-row { display: flex; align-items: center; gap: 14px; padding: 13px; border-radius: var(--radius-sm); background: var(--surface-alt); margin-bottom: 10px; }
.list-row .av { width: 40px; height: 40px; border-radius: 12px; background: var(--surface-muted); color: var(--surface-darkest); display: grid; place-items: center; flex-shrink: 0; }
.list-row .av svg { width: 20px; height: 20px; }
.list-row .info { flex: 1; min-width: 0; }
.list-row .info b { font-size: 14.5px; font-weight: 600; }
.list-row .info small { display: block; color: var(--text-muted); font-size: 12.5px; }
.bars { display: flex; gap: 3px; }
.bars i { width: 6px; height: 18px; border-radius: 3px; background: var(--border); }
.bars i.on { background: var(--accent); }

/* ---- Utilities ---- */
.muted { color: var(--text-muted); }
.accent { color: var(--accent-2); }
.flex { display: flex; }
.items-center { align-items: center; }
.gap { gap: 12px; }
.mt { margin-top: 16px; } .mb { margin-bottom: 16px; }

/* ---- Responsive ---- */
@media (max-width: 880px) {
  .layout-wrapper { flex-direction: column; padding: 12px; }
  .side-nav { width: auto; position: static; max-height: none; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side-nav .nav-spacer, .side-nav .nav-section { display: none; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3, .grid-2, .row-2-1 { grid-template-columns: 1fr; }
}
