:root {
  --bg: #f7f3eb;
  --panel: #ffffff;
  --panel-soft: #fffaf0;
  --text: #1f1712;
  --muted: #6f6258;
  --primary: #b68a35;
  --primary-dark: #8f6923;
  --accent: #2f241d;
  --accent-2: #1a1411;
  --danger: #9f2f21;
  --success-bg: #eef8ef;
  --success-text: #23613a;
  --error-bg: #fff0ec;
  --error-text: #8a2518;
  --border: #e8dcc9;
  --shadow-lg: 0 20px 50px rgba(31, 23, 18, 0.10);
  --shadow-md: 0 10px 30px rgba(31, 23, 18, 0.08);
  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;
}

* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }
body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  background:
    radial-gradient(circle at top left, rgba(182, 138, 53, 0.12), transparent 28%),
    linear-gradient(180deg, #fcfaf7 0%, var(--bg) 100%);
  color: var(--text);
}

a { color: var(--primary-dark); text-decoration: none; }
a:hover { color: var(--primary); }

h1, h2, h3, .brand-title, .card-title {
  font-family: 'Playfair Display', serif;
  letter-spacing: 0.2px;
}

h1, h2, h3, h4, p { margin-top: 0; }

.login-page {
  display:flex;
  align-items:center;
  justify-content:center;
  min-height:100vh;
  padding:20px;
}

.login-card {
  width: 100%;
  max-width: 430px;
  background: rgba(255,255,255,0.94);
  backdrop-filter: blur(8px);
  padding: 34px;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(182, 138, 53, 0.18);
  box-shadow: var(--shadow-lg);
}

.login-card h1, .login-card h2 {
  color: var(--accent-2);
  margin-bottom: 10px;
}

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

.sidebar {
  width: 290px;
  background: linear-gradient(180deg, #1a1411 0%, #2b211b 100%);
  color:#fff;
  padding:24px 20px;
  flex-shrink: 0;
  transition: transform .25s ease;
  box-shadow: 8px 0 30px rgba(0,0,0,.08);
}

.sidebar-brand {
  display:flex;
  align-items:center;
  gap:14px;
  padding: 4px 6px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand-badge {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, #d7b56a, var(--primary-dark));
  color: #1a1411;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight: 800;
  box-shadow: 0 10px 20px rgba(182,138,53,.25);
}

.sidebar-brand h2 {
  margin: 0;
  font-size: 1.2rem;
  color: #fff6e4;
}

.sidebar-brand p {
  margin: 4px 0 0;
  color: rgba(255,255,255,.68);
  font-size: .92rem;
}

.sidebar-user-card {
  margin-top: 20px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 18px;
  padding: 16px;
  display:flex;
  flex-direction:column;
  gap:10px;
}

.role-chip {
  align-self: flex-start;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(182, 138, 53, .18);
  color: #f4d68f;
  font-size: .84rem;
  text-transform: capitalize;
  border: 1px solid rgba(214,181,106,.18);
}

.sidebar nav {
  display:flex;
  flex-direction:column;
  gap:10px;
  margin-top:24px;
}

.sidebar a {
  color:#f7efe4;
  text-decoration:none;
  padding:13px 14px;
  border-radius:14px;
  background:rgba(255,255,255,.035);
  border: 1px solid transparent;
  transition: all .18s ease;
  font-weight: 500;
}

.sidebar a:hover,
.sidebar a.active {
  background: linear-gradient(135deg, rgba(182,138,53,.24), rgba(182,138,53,.08));
  border-color: rgba(214,181,106,.24);
  transform: translateX(2px);
}

.sidebar .logout-link {
  margin-top: 8px;
  color: #ffd8cf;
}

.content {
  flex:1;
  min-width: 0;
  padding:32px;
}

.page-shell {
  max-width: 1320px;
  margin: 0 auto;
}

.cards {
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap:18px;
  margin: 20px 0;
}

.cards-2 { max-width: 320px; }

.card, .panel {
  background: linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(255,250,240,0.96) 100%);
  border-radius: var(--radius-xl);
  padding: 22px;
  box-shadow: var(--shadow-md);
  border:1px solid var(--border);
}

.card {
  position: relative;
  overflow: hidden;
}

.card::after {
  content: "";
  position: absolute;
  right: -30px;
  top: -30px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(182,138,53,.16), transparent 65%);
}

.card strong, .card h3 {
  font-size: 1.8rem;
  color: var(--accent-2);
}

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

.inline-actions,
.actions-cell {
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

.btn, button {
  appearance: none;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color:#fff;
  border:none;
  padding:12px 18px;
  border-radius:14px;
  cursor:pointer;
  text-decoration:none;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  text-align:center;
  font-weight: 600;
  box-shadow: 0 10px 18px rgba(182,138,53,.22);
  transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease;
}

button:hover, .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 24px rgba(182,138,53,.28);
  opacity: .98;
}

.btn-outline {
  background: #fff;
  color: var(--primary-dark);
  border: 1px solid rgba(182,138,53,.34);
  box-shadow: none;
}

.btn-danger {
  background: linear-gradient(135deg, #c94a3b, var(--danger));
  box-shadow: 0 10px 18px rgba(159,47,33,.20);
}

input, select, textarea {
  width:100%;
  padding:13px 14px;
  margin:6px 0 14px;
  border:1px solid var(--border);
  border-radius:14px;
  background:#fff;
  color: var(--text);
  font-family: inherit;
  transition: border-color .18s ease, box-shadow .18s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: rgba(182,138,53,.58);
  box-shadow: 0 0 0 4px rgba(182,138,53,.10);
}

label {
  display:block;
  margin-bottom:8px;
  font-weight: 600;
  color: var(--accent);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 18px;
}

table {
  width:100%;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
  border:1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
}

th, td {
  text-align:left;
  padding:14px 16px;
  border-bottom:1px solid #efe5d6;
  vertical-align: top;
}

th {
  background: linear-gradient(180deg, #fff6e6 0%, #fcf2dd 100%);
  color: #5f4517;
  font-size: .92rem;
  font-weight: 700;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(182,138,53,.03); }

.alert {
  padding:14px 16px;
  border-radius:14px;
  margin-bottom:16px;
  border: 1px solid transparent;
}

.alert.success {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: #cfe8d4;
}

.alert.error {
  background: var(--error-bg);
  color: var(--error-text);
  border-color: #f0cfc8;
}

.search-bar {
  display:flex;
  gap:10px;
  margin-bottom:16px;
}

.search-bar input, .search-bar select { margin:0; }
.multi-search-bar { align-items:stretch; }
.detail-grid { display:grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap:14px; }
.full-width { grid-column: 1 / -1; }
.preview-frame { width:100%; height:700px; border:1px solid var(--border); border-radius:18px; background: #fff; }

.global-loader {
  position:fixed;
  inset:0;
  background:rgba(20, 15, 11, .42);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index:9999;
}

.global-loader.hidden { display:none; }

.loader-box {
  background:#fff;
  padding:28px 30px;
  border-radius:20px;
  text-align:center;
  box-shadow:var(--shadow-lg);
  border: 1px solid var(--border);
}

.spinner {
  width:50px;
  height:50px;
  border:4px solid #eadfcf;
  border-top-color: var(--primary);
  border-radius:50%;
  animation: spin .8s linear infinite;
  margin:0 auto 12px;
}

.mobile-topbar {
  display:none;
  align-items:center;
  justify-content:space-between;
  padding:14px 16px;
  background: linear-gradient(135deg, #1a1411, #2b211b);
  color:#fff;
  position:sticky;
  top:0;
  z-index:1000;
  box-shadow: 0 8px 20px rgba(0,0,0,.12);
}

.menu-toggle {
  background:rgba(255,255,255,.10);
  padding:10px 14px;
  box-shadow: none;
}

.mobile-brand {
  font-family: 'Playfair Display', serif;
  font-weight:700;
  color: #f6df9a;
}

.form-panel { max-width: 860px; }
.muted { color: var(--muted); }
.text-right { text-align: right; }
.section-title { margin-bottom: 4px; color: var(--accent-2); }
.section-subtitle { color: var(--muted); margin-bottom: 18px; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1100px) {
  .content { padding:24px; }
}

@media (max-width: 900px) {
  .content { padding:20px; }
  .detail-grid { grid-template-columns: 1fr; }
  .search-bar { flex-direction:column; }
}

@media (max-width: 768px) {
  .mobile-topbar { display:flex; }
  .app-shell { display:block; min-height:auto; }
  .sidebar {
    position:fixed;
    top:58px;
    left:0;
    width:min(84vw, 310px);
    height:calc(100vh - 58px);
    z-index:999;
    transform:translateX(-100%);
    overflow-y:auto;
  }
  .sidebar.open { transform:translateX(0); }
  .content { padding:16px; }
  .page-shell { max-width: 100%; }
  .cards { grid-template-columns: 1fr; }
  .cards-2 { max-width:none; }
  .btn, button { width:100%; }
  .inline-actions .btn, .inline-actions button,
  .actions-cell .btn, .actions-cell button { width:auto; }
  table, thead, tbody, th, td, tr { display:block; }
  thead { display:none; }
  .table-responsive { overflow:visible; border-radius: 0; }
  table { border:0; background: transparent; }
  tbody { display:flex; flex-direction:column; gap:12px; }
  tr {
    background: var(--panel);
    border:1px solid var(--border);
    border-radius:16px;
    padding:14px;
    box-shadow: 0 6px 16px rgba(0,0,0,.04);
  }
  td {
    border-bottom:none;
    padding:8px 0;
    white-space:normal;
    background: transparent !important;
  }
  td::before {
    content: attr(data-label);
    display:block;
    font-weight:700;
    margin-bottom:4px;
    color: var(--muted);
  }
  .preview-frame { height:500px; }
}


.upload-progress-box {
  margin-top: 14px;
  min-width: 240px;
}
.upload-progress-box.hidden { display: none; }
.upload-progress-bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #efe4ce;
  overflow: hidden;
  margin-bottom: 8px;
}
.upload-progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary) 0%, #d9b161 100%);
  transition: width .2s ease;
}
.form-hint {
  display: block;
  margin-top: -4px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}


.permissions-box {
  margin: 10px 0 14px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 250, 240, 0.72);
}

.permission-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 12px;
  font-weight: 500;
  line-height: 1.5;
  cursor: pointer;
}

.permission-option:last-child {
  margin-bottom: 0;
}

.permission-option input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  flex: 0 0 18px;
}

.permission-option span {
  display: block;
}

.single-option {
  margin-top: 6px;
  margin-bottom: 18px;
}
