/* =====================================================================
   Imperial Cabinets & Millwork — Referral Partner Platform
   Brand colors: navy/black bg, gold accent, white surfaces, soft gray
   ===================================================================== */

:root {
  --navy:        #0B0F1A;     /* near-black brand */
  --navy-2:      #141A2A;
  --navy-3:      #1B2236;
  --gold:        #C9A24B;     /* logo crown gold */
  --gold-light:  #E0BD68;
  --paper:       #FAFAFA;
  --paper-2:     #F2F2F4;
  --line:        #E2E4EA;
  --text:        #1A1F2E;
  --text-soft:   #5B6378;
  --text-mute:   #8A92A6;
  --white:       #FFFFFF;

  --green:       #2E8B57;
  --green-soft:  #DDF1E2;
  --red:         #C0392B;
  --red-soft:    #FBE3DF;
  --yellow:      #B68B0E;
  --yellow-soft: #FFF1C4;
  --blue:        #2C5C8F;
  --blue-soft:   #DCE7F4;
  --orange:      #C26A1B;
  --orange-soft: #FFE3CB;
  --gray:        #6E7383;
  --gray-soft:   #E5E6EB;

  --radius:      10px;
  --radius-sm:   6px;
  --shadow:      0 1px 3px rgba(0,0,0,.06), 0 6px 18px rgba(11,15,26,.08);
  --shadow-lg:   0 10px 30px rgba(11,15,26,.18);
  --font:        -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif:       "Playfair Display", "Cormorant Garamond", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
pre, code { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; }

/* =================== LANDING =================== */
.landing-body {
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-2) 60%, var(--navy-3) 100%);
  min-height: 100vh;
  color: var(--white);
}
.landing-header {
  display: flex; align-items: center; justify-content: center;
  position: relative;
  max-width: 1100px; margin: 0 auto; padding: 22px 24px;
}
.landing-header nav {
  position: absolute;
  right: 24px;
}
.landing-logo {
  width: 360px;
  height: auto;
  max-height: 192px;
  object-fit: contain;
}
.landing-hero {
  text-align: center; max-width: 820px; margin: 60px auto 40px; padding: 0 24px;
}
.landing-hero h1 {
  font-family: var(--serif);
  font-size: 56px; line-height: 1.05; margin: 0 0 16px;
  font-weight: 600; letter-spacing: 0.5px;
}
.hero-tag {
  color: var(--gold-light); font-size: 22px; margin: 0 0 16px; font-weight: 400;
}
.hero-sub {
  color: rgba(255,255,255,.78); font-size: 17px; max-width: 580px; margin: 0 auto 36px;
}
.hero-cta { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.landing-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px;
  max-width: 1100px; margin: 40px auto 80px; padding: 0 24px;
}
.landing-tile {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius); padding: 28px; backdrop-filter: blur(6px);
}
.tile-num {
  font-family: var(--serif); font-size: 36px; color: var(--gold-light);
  margin-bottom: 10px; font-weight: 600;
}
.landing-tile h3 { color: var(--white); font-size: 18px; margin: 0 0 8px; }
.landing-tile p  { color: rgba(255,255,255,.7); margin: 0; }
.landing-footer {
  text-align: center; padding: 28px 24px;
  color: rgba(255,255,255,.55); font-size: 13px;
}
.landing-footer a { color: var(--gold-light); }
@media (max-width: 720px) {
  .landing-header {
    flex-direction: column;
    gap: 18px;
  }
  .landing-header nav {
    position: static;
  }
  .landing-logo {
    width: min(320px, 86vw);
  }
  .landing-hero h1 { font-size: 36px; }
  .landing-grid { grid-template-columns: 1fr; }
}

/* =================== PUBLIC (login/register) =================== */
.public-body {
  background: var(--navy);
  min-height: 100vh; display: flex; flex-direction: column; align-items: center;
  padding: 40px 16px;
}
.public-shell { width: 100%; max-width: 460px; }
.public-card {
  background: var(--white); border-radius: var(--radius); padding: 36px 32px;
  box-shadow: var(--shadow-lg);
}
.public-logo { text-align: center; margin-bottom: 24px; }
.public-logo img {
  display: inline-block;
  width: min(320px, 100%);
  height: auto;
  object-fit: contain;
}
.public-title {
  font-family: var(--serif);
  font-size: 26px; margin: 0 0 6px; color: var(--navy); text-align: center;
  font-weight: 600; letter-spacing: 0.3px;
}
.public-sub { color: var(--text-soft); margin: 0 0 24px; text-align: center; font-size: 14px; }
.public-footer { color: rgba(255,255,255,.55); font-size: 13px; margin-top: 24px; text-align: center; }
.public-footer a { color: var(--gold-light); }
.form-foot { margin-top: 18px; text-align: center; font-size: 14px; color: var(--text-soft); }

.public-shell { max-width: 560px; }
.public-shell .public-card { padding: 40px 36px; }

/* Wider card on register page */
body.public-body[data-page="register"] .public-shell { max-width: 720px; }

/* =================== APP SHELL =================== */
.app-body { background: var(--paper); min-height: 100vh; display: flex; flex-direction: column; }
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 28px; background: var(--navy); color: var(--white);
  box-shadow: var(--shadow);
}
.app-header .brand { display: flex; align-items: center; }
.brand-logo {
  width: 112px;
  height: auto;
  max-height: 78px;
  object-fit: contain;
}
.app-nav-top { display: flex; align-items: center; gap: 16px; }
.user-chip {
  display: inline-flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.07); padding: 6px 12px; border-radius: 30px;
  font-size: 13px;
}
.user-role {
  font-size: 10px; font-weight: 700; letter-spacing: 0.6px;
  background: var(--gold); color: var(--navy);
  padding: 3px 8px; border-radius: 20px;
}
.user-role.role-admin  { background: var(--gold); }
.user-role.role-sales  { background: var(--blue-soft); color: var(--blue); }
.user-role.role-vendor { background: rgba(255,255,255,.18); color: var(--white); }

.app-shell { display: flex; flex: 1; min-height: 0; }
.app-sidebar {
  width: 240px; background: var(--white); border-right: 1px solid var(--line);
  padding: 24px 0; flex-shrink: 0;
}
.sidebar-nav { display: flex; flex-direction: column; }
.sidebar-nav a {
  padding: 11px 24px; color: var(--text); border-left: 3px solid transparent;
  font-size: 14px;
}
.sidebar-nav a:hover { background: var(--paper-2); text-decoration: none; }
.sidebar-nav a.active {
  background: var(--paper-2); border-left-color: var(--gold);
  font-weight: 600; color: var(--navy);
}
.app-main { flex: 1; padding: 32px 36px; min-width: 0; }
.app-footer {
  padding: 18px 28px; text-align: center; font-size: 13px;
  color: var(--text-mute); border-top: 1px solid var(--line);
  background: var(--white);
}
.app-footer a { color: var(--text-mute); }
@media (max-width: 880px) {
  .app-shell { flex-direction: column; }
  .app-sidebar { width: 100%; border-right: 0; border-bottom: 1px solid var(--line); padding: 12px 0; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; gap: 0; }
  .sidebar-nav a { border-left: 0; border-bottom: 3px solid transparent; padding: 10px 14px; }
  .sidebar-nav a.active { border-left: 0; border-bottom-color: var(--gold); }
  .app-main { padding: 20px 16px; }
}

/* =================== TYPOGRAPHY =================== */
.page-title {
  font-family: var(--serif);
  font-size: 30px; margin: 0 0 6px; color: var(--navy); font-weight: 600; letter-spacing: 0.3px;
}
.page-sub { color: var(--text-soft); margin: 0 0 28px; font-size: 14px; }
.sub-title { font-size: 16px; margin: 24px 0 8px; color: var(--navy); }
.muted { color: var(--text-mute); }
.muted.small { font-size: 12px; }
.req { color: var(--red); }
.back-link { display: inline-block; margin-bottom: 12px; color: var(--text-soft); font-size: 13px; }

/* =================== METRIC CARDS =================== */
.metric-row {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  margin-bottom: 24px;
}
.metric-card {
  background: var(--white); border-radius: var(--radius); padding: 18px 20px;
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.metric-card.highlight { border-color: var(--gold); background: linear-gradient(180deg, #FFFBF0 0%, #FFFFFF 100%); }
.metric-card.warn      { border-color: var(--yellow); background: #FFFCF0; }
.metric-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--text-mute); margin-bottom: 8px; font-weight: 600;
}
.metric-value { font-size: 24px; font-weight: 700; color: var(--navy); line-height: 1.1; }

/* =================== PANELS =================== */
.panel {
  background: var(--white); border-radius: var(--radius); padding: 22px 24px;
  border: 1px solid var(--line); box-shadow: var(--shadow); margin-bottom: 20px;
}
.panel-title {
  font-size: 16px; margin: 0 0 14px; color: var(--navy); font-weight: 600;
  padding-bottom: 12px; border-bottom: 1px solid var(--line);
}
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 880px) { .two-col { grid-template-columns: 1fr; } }

/* =================== TABLES =================== */
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-mute); font-weight: 700; padding: 10px 12px;
  border-bottom: 2px solid var(--line); background: var(--paper-2);
}
.data-table tbody td {
  padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top;
}
.data-table tbody tr:hover { background: var(--paper-2); }
.data-table .addr { max-width: 220px; font-size: 13px; color: var(--text-soft); }
.data-table .actions { white-space: nowrap; }
.data-table tr.row-warn { background: #FFFCF0; }

.detail-table { width: 100%; font-size: 14px; border-collapse: collapse; }
.detail-table th {
  text-align: left; width: 35%; padding: 8px 12px 8px 0;
  color: var(--text-mute); font-weight: 500; vertical-align: top;
}
.detail-table td { padding: 8px 0; color: var(--text); }

/* =================== BADGES =================== */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.4px;
  background: var(--gray-soft); color: var(--gray);
}
.badge-green  { background: var(--green-soft);  color: var(--green); }
.badge-red    { background: var(--red-soft);    color: var(--red); }
.badge-yellow { background: var(--yellow-soft); color: var(--yellow); }
.badge-blue   { background: var(--blue-soft);   color: var(--blue); }
.badge-orange { background: var(--orange-soft); color: var(--orange); }
.badge-gray   { background: var(--gray-soft);   color: var(--gray); }

/* =================== BUTTONS =================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; font-size: 14px; font-weight: 600; line-height: 1.2;
  border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer;
  text-decoration: none; transition: all 120ms ease;
  font-family: inherit; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--navy); color: var(--white); border-color: var(--navy); }
.btn-primary:hover { background: var(--navy-2); }
.btn-outline { background: var(--white); color: var(--navy); border-color: var(--navy); }
.btn-outline:hover { background: var(--paper-2); }
.btn-ghost   { background: transparent; color: var(--text-soft); }
.btn-ghost:hover { background: var(--paper-2); color: var(--navy); }
.btn-large { padding: 14px 26px; font-size: 15px; }
.btn-sm    { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* =================== FORMS =================== */
.form { display: flex; flex-direction: column; gap: 14px; }
.form-wide { max-width: 720px; }
.form-row  { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }
.form-section { padding: 16px 0; border-bottom: 1px dashed var(--line); }
.form-section:last-child { border-bottom: 0; }
.form-section h3 { font-size: 14px; color: var(--navy); margin: 0 0 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.form label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--text-soft);
}
.form input[type=text], .form input[type=email], .form input[type=tel],
.form input[type=password], .form input[type=number], .form input[type=url],
.form input[type=search], .form select, .form textarea {
  font: inherit; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--white); color: var(--text);
}
.form input:focus, .form select:focus, .form textarea:focus {
  outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(11,15,26,.08);
}
.form input[disabled] { background: var(--paper-2); color: var(--text-mute); }
.form textarea { font-family: inherit; resize: vertical; min-height: 64px; }
.form input[type=file] { padding: 6px 0; font-size: 13px; }
.form .checkbox-inline {
  flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 400; color: var(--text);
}
.form .checkbox-inline input { margin-top: 3px; }
.form-inline { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.inline-form { display: inline-flex; gap: 6px; align-items: center; }
.inline-form input, .inline-form select { padding: 6px 10px; font-size: 13px; }

.filter-bar { display: flex; gap: 10px; margin-bottom: 18px; align-items: center; flex-wrap: wrap; }
.filter-bar input[type=search], .filter-bar select {
  padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); font: inherit;
  background: var(--white);
}

/* =================== ALERTS =================== */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; }
.alert-success { background: var(--green-soft); color: var(--green); border-left: 4px solid var(--green); }
.alert-error   { background: var(--red-soft);   color: var(--red);   border-left: 4px solid var(--red); }
.alert-info    { background: var(--blue-soft);  color: var(--blue);  border-left: 4px solid var(--blue); }

/* =================== ACTIVITY =================== */
.activity-list { list-style: none; padding: 0; margin: 0; }
.activity-list li {
  display: grid; grid-template-columns: 160px 140px 1fr; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px;
}
.activity-list li:last-child { border-bottom: 0; }
.activity-when { color: var(--text-mute); }
.activity-event {
  display: inline-block; padding: 2px 8px; border-radius: 14px;
  background: var(--paper-2); font-size: 11px; font-weight: 700; color: var(--text-soft);
  letter-spacing: 0.3px; align-self: start; width: fit-content;
}
.activity-desc { color: var(--text); }
@media (max-width: 700px) {
  .activity-list li { grid-template-columns: 1fr; gap: 4px; }
}

/* =================== MISC =================== */
.notes-block {
  white-space: pre-wrap; font-family: var(--font); font-size: 14px;
  background: var(--paper-2); padding: 14px 16px; border-radius: var(--radius-sm);
  margin-top: 12px; line-height: 1.55;
}
.file-list { list-style: none; padding: 0; margin: 0; }
.file-list li {
  padding: 10px 0; border-bottom: 1px solid var(--line);
  display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap;
}
.file-list li:last-child { border-bottom: 0; }
.empty-state {
  text-align: center; padding: 60px 24px; color: var(--text-soft);
  background: var(--paper-2); border-radius: var(--radius); border: 1px dashed var(--line);
}
.empty-state h3 { color: var(--navy); margin: 0 0 6px; }
.quick-cta { display: flex; gap: 12px; margin: 16px 0 28px; flex-wrap: wrap; }
.template-row { margin-bottom: 10px; padding: 12px; background: var(--paper-2); border-radius: var(--radius-sm); }
.template-row summary { cursor: pointer; user-select: none; padding: 6px 0; }
.template-row[open] summary { margin-bottom: 12px; }
