/* LakazRent MU — Responsive Mobile-First & Print Stylesheet */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-muted: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #0f766e;
  --primary-hover: #115e59;
  --primary-light: #f0fdfa;
  --primary-border: #99f6e4;
  --amber: #d97706;
  --amber-bg: #fffbeb;
  --amber-border: #fde68a;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --red-border: #fecaca;
  --green: #15803d;
  --green-bg: #f0fdf4;
  --green-border: #bbf7d0;
  --blue: #1d4ed8;
  --blue-bg: #eff6ff;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* Sidebar (Desktop) */
.sidebar {
  width: 272px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px;
}

.brand img, .brand svg {
  width: 38px;
  height: 38px;
  border-radius: 10px;
}

.brand-title {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  color: var(--text);
}

.brand-sub {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-weight: 500;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.nav-btn:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.nav-btn.active {
  background: var(--primary-light);
  color: var(--primary);
}

.sidebar-card {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  font-size: 0.8rem;
}

.sidebar-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 6px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #e2e8f0;
  padding: 3px;
  border-radius: 8px;
  gap: 3px;
}

.segmented button {
  border: none;
  background: transparent;
  padding: 6px 8px;
  font-size: 0.76rem;
  font-weight: 700;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-muted);
}

.segmented button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

/* Main Content */
.main-area {
  flex: 1;
  min-width: 0;
  padding: 24px 28px 96px;
  max-width: 1200px;
  margin: 0 auto;
}

.mobile-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}

.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  z-index: 40;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
}

.mobile-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.67rem;
  font-weight: 600;
  padding: 6px 2px;
  border-radius: 8px;
  cursor: pointer;
}

.mobile-tab.active {
  color: var(--primary);
  background: var(--primary-light);
}

/* Typography & Layout Helpers */
.page-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 22px;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 2px;
}

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

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

.kpi-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.kpi-value {
  font-size: 1.55rem;
  font-weight: 800;
  margin-top: 6px;
  letter-spacing: -0.02em;
}

.kpi-foot {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Alerts & Badges */
.alert {
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.85rem;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid transparent;
}

.alert-amber {
  background: var(--amber-bg);
  border-color: var(--amber-border);
  color: #92400e;
}

.alert-red {
  background: var(--red-bg);
  border-color: var(--red-border);
  color: #991b1b;
}

.alert-green {
  background: var(--green-bg);
  border-color: var(--green-border);
  color: #166534;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}

.badge-green { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.badge-amber { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber-border); }
.badge-red { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-border); }
.badge-blue { background: var(--blue-bg); color: var(--blue); border: 1px solid #bfdbfe; }
.badge-teal { background: var(--primary-light); color: var(--primary); border: 1px solid var(--primary-border); }

/* Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 9px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: all 0.15s ease;
}

.btn:hover { background: var(--surface-muted); }

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.btn-primary:hover { background: var(--primary-hover); }

.btn-sm {
  padding: 5px 10px;
  font-size: 0.76rem;
  border-radius: 7px;
}

.btn-danger {
  color: var(--red);
  border-color: var(--red-border);
  background: var(--red-bg);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

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

.field label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.field input, .field select, .field textarea {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.88rem;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}

.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--primary-border);
  border-color: var(--primary);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  cursor: pointer;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

th {
  text-align: left;
  padding: 10px 12px;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
}

td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

/* Document Preview / Print Sheet */
.doc-preview {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 28px;
  font-size: 0.86rem;
  line-height: 1.65;
  color: #1e293b;
}

.doc-preview h3 {
  text-align: center;
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.doc-preview .doc-sub {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 2px solid #0f172a;
}

.doc-clause {
  margin-bottom: 12px;
}

.doc-clause strong {
  color: #0f172a;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-box {
  background: var(--surface);
  border-radius: 16px;
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.15);
}

.toast {
  position: fixed;
  bottom: 84px;
  right: 20px;
  background: #0f172a;
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.84rem;
  font-weight: 600;
  z-index: 120;
  box-shadow: 0 10px 15px rgba(0,0,0,0.2);
}

@media (max-width: 900px) {
  .sidebar { display: none; }
  .mobile-topbar { display: flex; }
  .mobile-bottom-nav { display: grid; }
  .app-shell { flex-direction: column; }
  .main-area { padding: 16px 14px 96px; width: 100%; }
  .grid-2 { grid-template-columns: 1fr; }
}

@media print {
  body { background: #ffffff; }
  .sidebar, .mobile-topbar, .mobile-bottom-nav, .no-print, .toast {
    display: none !important;
  }
  .main-area {
    padding: 0 !important;
    max-width: 100% !important;
  }
  .modal-backdrop {
    position: static !important;
    background: none !important;
    padding: 0 !important;
  }
  .modal-box, .doc-preview {
    box-shadow: none !important;
    border: none !important;
    max-height: none !important;
    padding: 0 !important;
  }
}
