/* Renlyo Internal Portal. Brand colors navy #082844, coral #FB6144, white #FFFFFF (docs/RENLYO_BRAND.md); neutrals are
   navy at reduced opacity, as in the app's design system. DejaVu Sans is the companion typeface (not the logo typeface).
   No gradients. Desktop-first, responsive down to phone width. */

@font-face {
  font-family: "DejaVu Sans";
  src: url("/static/fonts/DejaVuSans.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "DejaVu Sans";
  src: url("/static/fonts/DejaVuSans-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: light;
  --navy: #082844;
  --coral: #fb6144;
  --white: #ffffff;
  --ink: var(--navy);
  --ink-2: rgba(8, 40, 68, 0.64);
  --ink-3: rgba(8, 40, 68, 0.42);
  --canvas: #f5f6f8;
  --surface: var(--white);
  --fill: rgba(8, 40, 68, 0.05);
  --hairline: rgba(8, 40, 68, 0.1);
  --navy-tint: rgba(8, 40, 68, 0.08);
  --coral-tint: rgba(251, 97, 68, 0.12);
  --coral-pressed: #e4553a;
  --success: #1f854d;
  --warning: #b36600;
  --danger: #c22929;
  --radius: 12px;
  --radius-small: 8px;
  --sidebar: 248px;
  --font: "DejaVu Sans", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 14px/1.5 var(--font);
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
:focus-visible { outline: 2px solid var(--coral); outline-offset: 2px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* MARK: Shell */

.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--navy); color: var(--white);
  padding: 20px 16px;
}
.sidebar-logo { display: block; padding: 0 4px 20px; }
.sidebar-logo img { display: block; width: 100%; max-width: 188px; height: auto; }
.sidebar-label { margin: 8px 12px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: rgba(255, 255, 255, 0.56); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 0 12px; border-radius: var(--radius-small);
  color: rgba(255, 255, 255, 0.78); text-decoration: none; font-weight: 700;
  border-left: 3px solid transparent;
}
.nav a:hover { background: rgba(255, 255, 255, 0.08); color: var(--white); }
.nav a[aria-current="page"] { background: rgba(255, 255, 255, 0.1); color: var(--white); border-left-color: var(--coral); }
.nav svg { width: 18px; height: 18px; flex: none; }
.sidebar-user { margin-top: auto; padding: 16px 12px 0; border-top: 1px solid rgba(255, 255, 255, 0.14); }
.sidebar-user-name { font-weight: 700; overflow-wrap: anywhere; }
.sidebar-user-role { font-size: 12px; color: rgba(255, 255, 255, 0.64); }
.sidebar-user .button { margin-top: 12px; width: 100%; }

.topbar { display: none; }
.main { min-width: 0; padding: 32px 40px 48px; }
.main-inner { max-width: 1200px; margin: 0 auto; }

/* MARK: Page header */

.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-title { font-size: 26px; }
.page-subtitle { margin-top: 4px; color: var(--ink-2); }
.breadcrumb { margin-bottom: 8px; font-size: 13px; color: var(--ink-2); }
.breadcrumb a { text-decoration: none; }
.breadcrumb a:hover { color: var(--coral); text-decoration: underline; }
.overline { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }

/* MARK: Controls */

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: var(--radius-small);
  border: 1px solid transparent; font-weight: 700; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.button-primary { background: var(--coral); color: var(--white); }
.button-primary:hover { background: var(--coral-pressed); }
.button-secondary { background: var(--surface); color: var(--navy); border-color: var(--hairline); }
.button-secondary:hover { background: var(--fill); }
.button-quiet { background: rgba(255, 255, 255, 0.08); color: var(--white); border-color: rgba(255, 255, 255, 0.2); }
.button-quiet:hover { background: rgba(255, 255, 255, 0.16); }
.button[disabled] { opacity: 0.5; cursor: default; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 13px; font-weight: 700; }
.field .optional { font-weight: 400; color: var(--ink-3); }
.input, .select {
  width: 100%; min-height: 44px; padding: 0 12px;
  background: var(--surface); border: 1px solid rgba(8, 40, 68, 0.2); border-radius: var(--radius-small);
}
.input:focus, .select:focus { border-color: var(--navy); outline: 2px solid var(--navy-tint); outline-offset: 0; }
.input[aria-invalid="true"] { border-color: var(--danger); }
.hint { font-size: 12px; color: var(--ink-2); }

.toolbar { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .search { flex: 1 1 280px; max-width: 420px; }
.toolbar .select { width: auto; min-width: 220px; }

.alert { padding: 12px 16px; border-radius: var(--radius-small); margin-bottom: 16px; }
.alert-error { background: rgba(194, 41, 41, 0.08); color: var(--danger); border: 1px solid rgba(194, 41, 41, 0.24); }
.alert-success { background: rgba(31, 133, 77, 0.08); color: var(--success); border: 1px solid rgba(31, 133, 77, 0.24); }

/* MARK: Cards */

.card { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius); }
.stack { display: flex; flex-direction: column; gap: 24px; min-width: 0; }
.spaced { margin-bottom: 24px; }
.toolbar + .card { margin-top: 0; }
.card-body { padding: 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--hairline); }
.card-title { font-size: 16px; }
.card-note { padding: 0 20px 16px; color: var(--ink-2); font-size: 13px; }
.section-title { font-size: 18px; margin-bottom: 12px; }

.grid { display: grid; gap: 24px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-sidebar { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }

.stat { display: block; padding: 20px; text-decoration: none; }
.stat:hover { border-color: var(--navy); }
.stat-label { color: var(--ink-2); font-weight: 700; }
.stat-value { margin-top: 8px; font-size: 34px; font-weight: 700; line-height: 1.1; }
.stat-link { margin-top: 12px; font-size: 13px; color: var(--coral); font-weight: 700; }

.details { display: grid; grid-template-columns: minmax(110px, max-content) minmax(0, 1fr); gap: 10px 20px; margin: 0; }
.details dt { color: var(--ink-2); }
.details dd { margin: 0; overflow-wrap: anywhere; }
.address { white-space: pre-line; }

/* MARK: Tables */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  padding: 10px 16px; text-align: left; font-size: 12px; font-weight: 700; color: var(--ink-2);
  border-bottom: 1px solid var(--hairline); white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--hairline); vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.table .numeric { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table tbody tr.row-link { cursor: pointer; }
.table tbody tr.row-link:hover td { background: var(--fill); }
.table a.primary { font-weight: 700; text-decoration: none; }
.table a.primary:hover { color: var(--coral); text-decoration: underline; }
.muted { color: var(--ink-2); }
.nowrap { white-space: nowrap; }
.small { font-size: 12px; }

.badge {
  display: inline-flex; align-items: center; min-height: 24px; padding: 0 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--navy-tint); color: var(--navy);
}
.badge-coral { background: var(--coral-tint); color: #b7381f; }
.badge-success { background: rgba(31, 133, 77, 0.1); color: var(--success); }
.badge-muted { background: var(--fill); color: var(--ink-2); }

.empty { padding: 32px 20px; text-align: center; color: var(--ink-2); }
.empty strong { display: block; color: var(--ink); margin-bottom: 4px; }
.load-more { display: flex; justify-content: center; padding: 16px; border-top: 1px solid var(--hairline); }
.loading { padding: 32px 20px; color: var(--ink-2); }

/* MARK: Forms */

.form { max-width: 760px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .span-2 { grid-column: span 2; }
.form-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; }

/* MARK: Order */

.money-rows { margin: 0; }
.money-row { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; }
.money-row dt { color: var(--ink-2); }
.money-row dd { margin: 0; font-variant-numeric: tabular-nums; white-space: nowrap; }
.money-row.strong dt, .money-row.strong dd { color: var(--ink); font-weight: 700; }
.money-row.total { margin-top: 8px; padding-top: 14px; border-top: 1px solid var(--hairline); font-size: 18px; }
.money-row.total dt, .money-row.total dd { color: var(--ink); font-weight: 700; }
.money-row.discount dd { color: var(--success); }
.line-section td { background: var(--fill); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); }

/* MARK: Login */

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 420px; padding: 32px; }
.login-logo { display: block; width: 220px; max-width: 100%; height: auto; margin: 0 auto 24px; }
.login-title { font-size: 20px; text-align: center; }
.login-subtitle { margin: 6px 0 24px; text-align: center; color: var(--ink-2); }
.login form { display: flex; flex-direction: column; gap: 16px; }
.login .button { width: 100%; margin-top: 8px; }
.login-footer { margin-top: 20px; text-align: center; font-size: 12px; color: var(--ink-3); }

/* MARK: Responsive */

@media (max-width: 1100px) {
  .grid-sidebar { grid-template-columns: minmax(0, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    height: 60px; padding: 0 16px; background: var(--navy);
  }
  .topbar img { height: 36px; width: auto; display: block; }
  .menu-button { min-height: 44px; min-width: 44px; padding: 0 12px; }
  .sidebar { display: none; position: fixed; top: 60px; left: 0; right: 0; bottom: 0; height: auto; z-index: 19; overflow-y: auto; }
  .shell.menu-open .sidebar { display: flex; }
  .sidebar-logo { display: none; }
  .main { padding: 24px 16px 40px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .page-title { font-size: 22px; }
}

@media (max-width: 600px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2 { grid-column: auto; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .button { width: 100%; }
  .toolbar .select, .toolbar .search { max-width: none; width: 100%; }
  .details { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .details dd { margin-bottom: 10px; }
  .card-body { padding: 16px; }
  .table th, .table td { padding: 10px 12px; }
  .table .hide-mobile { display: none; }
  .login-card { padding: 24px 20px; }
}
