/* ============================================================================
 * WayFlow Mini — WYWK Brand Design System
 * Palette: Dark Grey #29352F | Ivory #F5F0E5 | Green #64866A | Soft Green #DCE8D9
 * ========================================================================== */

:root {
  --bg-ivory: #F5F0E5;
  --surface-white: #FFFFFF;
  --surface-soft: #FAF7F0;
  --brand-dark: #29352F;
  --brand-dark-hover: #1E2722;
  --brand-green: #64866A;
  --brand-green-hover: #537259;
  --brand-soft-green: #DCE8D9;
  --text-primary: #29352F;
  --text-muted: #5C6B63;
  --border-subtle: #E4DDD0;
  --danger: #B8423B;
  --danger-bg: #FDECEA;
  --warning: #B4690E;
  --warning-bg: #FEF4E6;
  --success: #2F6F44;
  --success-bg: #E6F3EA;

  --sidebar-width: 240px;
  --topbar-height: 64px;
  --radius-card: 14px;
  --radius-btn: 10px;
  --shadow-card: 0 1px 3px rgba(41, 53, 47, 0.06), 0 4px 12px rgba(41, 53, 47, 0.03);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Plus Jakarta Sans', 'Inter', 'Noto Sans Malayalam', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background-color: var(--bg-ivory);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  touch-action: pan-x pan-y;
  overflow-x: hidden;
}

.num, .kpi-value, td.num, th.num {
  font-variant-numeric: tabular-nums;
}

/* Layout Shell */
.app-shell[hidden], .landing-page[hidden] {
  display: none !important;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Public Landing Page */
.landing-page {
  min-height: 100vh;
  background: var(--bg-ivory);
  display: flex;
  flex-direction: column;
}

.landing-nav {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.landing-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.landing-brand-name {
  font-weight: 700;
  font-size: 17px;
  color: var(--brand-dark);
}

.landing-brand-sub {
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--brand-green);
  font-weight: 700;
}

.landing-nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.landing-hero {
  max-width: 1040px;
  width: 100%;
  margin: 0 auto;
  padding: 48px 24px 64px;
  text-align: center;
}

.landing-pill {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--brand-soft-green);
  color: var(--brand-dark);
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 18px;
}

.landing-title {
  margin: 0 auto 14px;
  max-width: 720px;
  font-size: clamp(28px, 4.5vw, 44px);
  line-height: 1.15;
  font-weight: 700;
  color: var(--brand-dark);
}

.landing-subtitle {
  margin: 0 auto 28px;
  max-width: 600px;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-muted);
}

.landing-cta-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 48px;
}

.landing-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  text-align: left;
}

.feature-card {
  background: var(--surface-white);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 20px;
  box-shadow: var(--shadow-card);
}

.feature-card svg {
  width: 22px;
  height: 22px;
  color: var(--brand-green);
  margin-bottom: 10px;
}

.feature-card h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.feature-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13.5px;
  line-height: 1.5;
}

.landing-mission {
  margin-top: 44px;
  background: var(--brand-dark);
  color: var(--bg-ivory);
  border-radius: var(--radius-card);
  padding: 32px 28px;
  text-align: center;
  box-shadow: var(--shadow-card);
}

.mission-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(100, 134, 106, 0.28);
  color: var(--brand-soft-green);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

.mission-badge svg {
  width: 14px;
  height: 14px;
}

.landing-mission h2 {
  margin: 0 0 10px;
  font-size: 24px;
  color: #FFFFFF;
}

.mission-lead {
  margin: 0 auto 10px;
  max-width: 680px;
  font-size: 16px;
  line-height: 1.6;
  color: var(--brand-soft-green);
}

.mission-body {
  margin: 0 auto;
  max-width: 640px;
  font-size: 14px;
  line-height: 1.6;
  color: rgba(245, 240, 229, 0.82);
}

.landing-faq {
  margin-top: 48px;
  text-align: left;
}

.landing-faq h2 {
  margin: 0 0 16px;
  font-size: 22px;
  text-align: center;
  color: var(--brand-dark);
}

.faq-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.faq-item {
  background: var(--surface-white);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 16px 18px;
}

.faq-item h3 {
  margin: 0 0 6px;
  font-size: 14.5px;
  color: var(--brand-dark);
}

.faq-item p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--brand-dark);
  color: var(--bg-ivory);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid rgba(245, 240, 229, 0.12);
}

.brand-logo-img {
  height: 48px;
  width: auto;
  display: block;
}

.brand-logo-sidebar {
  height: 38px;
  width: auto;
  display: block;
  flex-shrink: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--brand-green);
  color: #FFFFFF;
  font-weight: 700;
  font-size: 17px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  flex: 1;
}

.brand-name {
  font-weight: 700;
  font-size: 15px;
  color: #FFFFFF;
}

.brand-sub {
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--brand-soft-green);
  opacity: 0.85;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-group-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(245, 240, 229, 0.5);
  padding: 12px 10px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: none;
  background: transparent;
  color: rgba(245, 240, 229, 0.82);
  border-radius: 9px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.nav-item svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #FFFFFF;
}

.nav-item.active {
  background: var(--brand-green);
  color: #FFFFFF;
  font-weight: 600;
}

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid rgba(245, 240, 229, 0.12);
  font-size: 11.5px;
  color: rgba(245, 240, 229, 0.7);
}

.mode-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-weight: 500;
  color: var(--brand-soft-green);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6EE7B7;
}

/* Main Wrapper */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: var(--topbar-height);
  background: var(--surface-white);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--brand-dark);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--border-subtle);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand-dark);
  color: var(--bg-ivory);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 12px;
}

.user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.user-name {
  font-size: 12.5px;
  font-weight: 600;
}

.user-role {
  font-size: 10px;
  color: var(--text-muted);
}

.main-content {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
  flex: 1;
}

/* Cards & Grids */
.card {
  background: var(--surface-white);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 18px 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.card-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--surface-white);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
}

.kpi-card.highlight {
  background: var(--brand-dark);
  color: var(--bg-ivory);
  border-color: var(--brand-dark);
}

.kpi-card.highlight .kpi-label,
.kpi-card.highlight .kpi-sub {
  color: var(--brand-soft-green);
}

.kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 25px;
  font-weight: 700;
  line-height: 1.2;
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.dashboard-split {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: var(--radius-btn);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
  min-height: 38px;
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brand-green);
  color: #FFFFFF;
}

.btn-primary:hover:not(:disabled) {
  background: var(--brand-green-hover);
}

.btn-dark {
  background: var(--brand-dark);
  color: var(--bg-ivory);
}

.btn-dark:hover:not(:disabled) {
  background: var(--brand-dark-hover);
}

.btn-secondary {
  background: var(--surface-white);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-soft);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(184, 66, 59, 0.25);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12.5px;
  min-height: 32px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: 1px solid var(--border-subtle);
  background: var(--surface-white);
  color: var(--text-primary);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* Forms & Inputs */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

input, select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-subtle);
  border-radius: 9px;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text-primary);
  background: var(--surface-white);
  min-height: 38px;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--brand-green);
  border-color: var(--brand-green);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.toolbar-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex: 1;
}

.search-input {
  max-width: 280px;
}

/* Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'Inter', 'Plus Jakarta Sans', sans-serif;
  font-size: 13px;
}

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

th {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-soft);
}

th.num, td.num {
  text-align: right;
}

tbody tr:hover {
  background: rgba(220, 232, 217, 0.25);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-neutral { background: var(--surface-soft); color: var(--text-muted); border: 1px solid var(--border-subtle); }

/* Chart */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 170px;
  padding-top: 16px;
}

.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
}

.bar-fill {
  width: 100%;
  max-width: 38px;
  background: var(--brand-green);
  border-radius: 6px 6px 0 0;
  min-height: 4px;
  transition: height 0.3s ease;
}

.bar-label {
  font-size: 11px;
  color: var(--text-muted);
}

/* Modal & Toast */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(41, 53, 47, 0.52);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 100;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-dialog {
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  background: var(--surface-white);
  border-radius: var(--radius-card);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.modal-body {
  padding: 18px;
  overflow-y: auto;
}

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 120;
}

.toast {
  background: var(--brand-dark);
  color: #FFFFFF;
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.toast.error { background: var(--danger); }
.toast.success { background: var(--brand-green); }

/* Mobile Responsiveness (360px, 375px, 412px, Tablet) */
.mobile-only { display: none; }
.mobile-bottom-nav { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 960px) {
  .dashboard-split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .mobile-only { display: inline-grid; }

  /* Prevent iOS auto-zoom on input focus */
  input, select, textarea {
    font-size: 16px;
  }

  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 35;
  }

  .main-wrapper {
    margin-left: 0;
    padding-bottom: 68px;
  }

  .topbar {
    padding: 0 14px;
  }

  .page-title {
    font-size: 18px;
  }

  .user-meta {
    display: none;
  }

  .main-content {
    padding: 14px;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .kpi-value {
    font-size: 20px;
  }

  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--surface-white);
    border-top: 1px solid var(--border-subtle);
    z-index: 30;
  }

  .bottom-nav-item {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
  }

  .bottom-nav-item svg {
    width: 18px;
    height: 18px;
  }

  .bottom-nav-item.active {
    color: var(--brand-green);
  }

  .toast-container {
    bottom: 72px;
    right: 12px;
    left: 12px;
  }
}

@media (max-width: 400px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
}

/* Print Invoice Styling */
@media print {
  .sidebar, .topbar, .mobile-bottom-nav, .no-print {
    display: none !important;
  }
  .main-wrapper {
    margin: 0 !important;
  }
  body {
    background: #FFFFFF !important;
  }
  .modal-overlay {
    position: static;
    background: none;
    padding: 0;
  }
  .modal-dialog {
    box-shadow: none;
    max-width: 100%;
  }
}
