:root {
  --oasoft-orange: #f68e13;
  --oasoft-orange-dark: #d97706;
  --oasoft-orange-light: #fff1de;
  --ink: #16181d;
  --ink-soft: #63666f;
  --ink-faint: #93969f;
  --bg: #f4f5f7;
  --card-bg: #ffffff;
  --border: #e7e8ec;
  --border-soft: #f0f1f4;
  --sidebar-bg: #14161c;
  --sidebar-ink: #c7c9d3;
  --sidebar-ink-dim: #7d808c;
  --sidebar-active-bg: #21242d;
  --green: #12805c;
  --green-bg: #e4f7ef;
  --red: #d1342b;
  --red-bg: #fdecea;
  --amber: #92620a;
  --amber-bg: #fff4dc;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 18, 24, 0.05);
  --shadow-md: 0 8px 24px rgba(16, 18, 24, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--oasoft-orange-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.4rem; font-weight: 700; margin: 0 0 0.75rem; letter-spacing: -0.01em; }
h2 { font-size: 1.02rem; font-weight: 700; margin: 1.75rem 0 0.75rem; letter-spacing: -0.005em; }
h2.no-top-margin { margin-top: 0; }

.icon { flex-shrink: 0; vertical-align: -3px; }

/* ---------- Auth / customer-facing pages ---------- */

.centered-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: linear-gradient(rgba(15, 17, 22, 0.55), rgba(15, 17, 22, 0.55)), url('/assets/img/wallpaper_oasoft.jpg');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}

.auth-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 2.75rem;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.logo { display: block; max-height: 52px; margin: 0 auto 1.5rem; }
.logo-sm { display: block; height: 26px; }

/* ---------- Forms ---------- */

form label {
  display: block;
  margin-bottom: 1rem;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

form input[type=text],
form input[type=email],
form input[type=password],
form input[type=number],
form input[type=datetime-local],
form select,
form textarea {
  display: block;
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.62rem 0.8rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-family: inherit;
  font-weight: normal;
  color: var(--ink);
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

form input:focus, form select:focus, form textarea:focus, .note-editor-html:focus {
  outline: none;
  border-color: var(--oasoft-orange);
  box-shadow: 0 0 0 3px var(--oasoft-orange-light);
}

.checkbox-label { display: flex; align-items: center; gap: 0.5rem; font-weight: normal; }
.checkbox-label input { width: auto; margin: 0; }

/* ---------- Buttons ---------- */

button, .btn {
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.1rem;
  font-size: 0.88rem;
  font-weight: 600;
  background: #eceef1;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: background 0.15s ease, transform 0.05s ease;
  font-family: inherit;
}
button:hover, .btn:hover { background: #e1e3e8; text-decoration: none; }
button:active, .btn:active { transform: translateY(1px); }

.btn-primary, form button[type=submit] {
  background: var(--oasoft-orange);
  color: #fff;
  box-shadow: 0 1px 0 rgba(0,0,0,0.05);
}
.btn-primary:hover, form button[type=submit]:hover { background: var(--oasoft-orange-dark); }

.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-danger:hover { background: #fbdcd9; }

.btn-link {
  background: none;
  border: none;
  color: var(--oasoft-orange-dark);
  padding: 0;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.btn-link:hover { text-decoration: underline; }
.btn-link-danger { color: var(--ink-faint); }
.btn-link-danger:hover { color: var(--red); }

button:disabled { opacity: 0.5; cursor: not-allowed; }
button:disabled:hover { background: #eceef1; }

/* ---------- Alerts ---------- */

.hint { color: var(--ink-soft); font-size: 0.88rem; }
.hint.small { font-size: 0.79rem; }

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  margin: 0 0 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  line-height: 1.5;
}
.alert .icon { margin-top: 0.15rem; }
.alert-error { background: var(--red-bg); color: var(--red); }
.alert-success { background: var(--green-bg); color: var(--green); }
.alert-warning { background: var(--amber-bg); color: var(--amber); }

/* ---------- App shell / sidebar ---------- */

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

.sidebar {
  width: 246px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-ink);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
  color: #fff;
  padding: 0.4rem 0.6rem 1.5rem;
  font-size: 0.95rem;
}
.sidebar .brand:hover { text-decoration: none; }
.sidebar .brand .logo-sm { filter: brightness(0) invert(1); opacity: 0.95; }

.side-nav { flex: 1; overflow-y: auto; }
.side-nav-group { margin-bottom: 1.4rem; }
.side-nav-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sidebar-ink-dim);
  margin: 0 0 0.5rem;
  padding: 0 0.6rem;
}

.side-nav a, .side-nav-footer a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.6rem;
  border-radius: var(--radius-sm);
  color: var(--sidebar-ink);
  font-size: 0.87rem;
  font-weight: 500;
  margin-bottom: 0.15rem;
}
.side-nav a:hover, .side-nav-footer a:hover {
  background: var(--sidebar-active-bg);
  color: #fff;
  text-decoration: none;
}
.side-nav a.active {
  background: var(--oasoft-orange);
  color: #fff;
  font-weight: 600;
}
.side-nav a span, .side-nav-footer a span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-nav-footer {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 0.75rem;
  margin-top: 0.5rem;
}
.side-nav-footer .logout-link:hover { background: var(--red); }

.main-col { flex: 1; min-width: 0; }
.admin-main { max-width: 1120px; margin: 0 auto; padding: 2.25rem 2rem 4rem; }

.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; }

/* ---------- Cards, tables, badges ---------- */

.card-form {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.6rem;
  max-width: 640px;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.card-form-wide { max-width: 920px; }

.card-form-inline { border: 1.5px dashed var(--border); border-radius: var(--radius-sm); padding: 1rem 1.1rem; margin: 1rem 0; }
.card-form-inline legend { font-weight: 700; padding: 0 0.4rem; font-size: 0.92rem; }

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

.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--card-bg); box-shadow: var(--shadow-sm); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 0.7rem 1rem; border-bottom: 1px solid var(--border-soft); font-size: 0.86rem; }
.table th { background: #fafafb; color: var(--ink-soft); font-weight: 600; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.03em; }
.table tbody tr:hover { background: #fafbfc; }
.table tr:last-child td { border-bottom: none; }
.ua-cell { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-faint); font-size: 0.78rem; }

.badge { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.2rem 0.65rem; border-radius: 999px; font-size: 0.74rem; font-weight: 700; }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-gray { background: #eceef1; color: var(--ink-soft); }

.actions-row { display: flex; gap: 1rem; align-items: center; margin-top: 1rem; flex-wrap: wrap; }
.inline-form { display: flex; gap: 0.5rem; align-items: center; }
.inline-form select { width: auto; margin: 0; }

.copy-row { display: flex; gap: 0.5rem; }
.copy-row input { flex: 1; font-family: ui-monospace, Consolas, monospace; font-size: 0.85rem; }
.copy-row button { flex-shrink: 0; }

.stat-row { display: flex; gap: 1.5rem; flex-wrap: wrap; margin: 0.75rem 0 0.25rem; }
.stat-tile {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1.1rem;
  min-width: 160px;
  flex: 1;
}
.stat-tile .stat-label { font-size: 0.75rem; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; margin-bottom: 0.3rem; }
.stat-tile .stat-value { font-size: 1.35rem; font-weight: 700; color: var(--ink); }
.stat-tile .stat-sub { font-size: 0.78rem; color: var(--ink-soft); margin-top: 0.15rem; }

/* ---------- Note / rich text ---------- */

.note-box {
  background: #fafbfc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.1rem;
  word-break: break-word;
  position: relative;
  line-height: 1.6;
}
.note-box p { margin: 0 0 0.75rem; }
.note-box p:last-child { margin-bottom: 0; }
.note-box ul, .note-box ol { margin: 0 0 0.75rem; padding-left: 1.5rem; }
.note-box code {
  background: #eee;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-family: ui-monospace, "Cascadia Code", Consolas, "Courier New", monospace;
  font-size: 0.9em;
}

.note-box-wrap { position: relative; }
.note-copy-btn {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.note-copy-btn:hover { background: #f1f1f1; }

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.4rem;
  font-weight: normal;
  flex-wrap: wrap;
}
.editor-btn {
  background: #f1f2f4;
  color: var(--ink-soft);
  padding: 0.32rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 6px;
}
.editor-btn:hover { background: #e5e6ea; }
.editor-btn[aria-pressed="true"] { background: var(--oasoft-orange); color: #fff; }
.editor-count { margin-left: auto; font-size: 0.76rem; color: var(--ink-faint); font-weight: normal; }

.note-editor-html {
  min-height: 8rem;
  max-height: 24rem;
  overflow-y: auto;
  line-height: 1.5;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.92rem;
  margin-top: 0.4rem;
}
.note-editor-html p { margin: 0 0 0.6rem; }
.note-editor-html ul, .note-editor-html ol { margin: 0 0 0.6rem; padding-left: 1.5rem; }
.note-editor-html code {
  background: #f1f1f1;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-family: ui-monospace, "Cascadia Code", Consolas, "Courier New", monospace;
  font-size: 0.9em;
}
.note-editor-html.is-empty:before {
  content: attr(data-placeholder);
  color: var(--ink-faint);
  pointer-events: none;
}

.file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 0.2rem;
  border-bottom: 1px solid var(--border-soft);
  gap: 1rem;
}
.file-row:last-child { border-bottom: none; }
.file-row > span { display: flex; align-items: center; gap: 0.5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#file-preview, #uploaded-list { list-style: none; padding: 0; margin: 0.5rem 0 1rem; font-size: 0.85rem; color: var(--ink-soft); }
#uploaded-list li { padding: 0.35rem 0; border-bottom: 1px solid var(--border-soft); }
#uploaded-list li:last-child { border-bottom: none; }

code { background: #f1f1f1; padding: 0.1rem 0.4rem; border-radius: 4px; font-size: 0.85em; word-break: break-all; }

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    flex-direction: column;
    padding: 1rem;
  }
  .side-nav { display: flex; flex-wrap: wrap; gap: 0.25rem; overflow: visible; }
  .side-nav-group { display: flex; align-items: center; gap: 0.25rem; margin-bottom: 0; }
  .side-nav-label { display: none; }
  .side-nav a span { display: none; }
  .side-nav-footer { display: flex; border-top: none; margin-top: 0.75rem; gap: 0.5rem; }
  .side-nav-footer a span { display: inline; }
  .admin-main { padding: 1.5rem 1.1rem 3rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .centered-page { background-attachment: scroll; }
}
